lkml.org 
[lkml]   [2022]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 112/234] random: only wake up writers after zap if threshold was passed
    Date
    From: "Jason A. Donenfeld" <Jason@zx2c4.com>

    commit a3f9e8910e1584d7725ef7d5ac870920d42d0bb4 upstream.

    The only time that we need to wake up /dev/random writers on
    RNDCLEARPOOL/RNDZAPPOOL is when we're changing from a value that is
    greater than or equal to POOL_MIN_BITS to zero, because if we're
    changing from below POOL_MIN_BITS to zero, the writers are already
    unblocked.

    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/char/random.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- a/drivers/char/random.c
    +++ b/drivers/char/random.c
    @@ -1577,7 +1577,7 @@ static long random_ioctl(struct file *f,
    */
    if (!capable(CAP_SYS_ADMIN))
    return -EPERM;
    - if (xchg(&input_pool.entropy_count, 0)) {
    + if (xchg(&input_pool.entropy_count, 0) >= POOL_MIN_BITS) {
    wake_up_interruptible(&random_write_wait);
    kill_fasync(&fasync, SIGIO, POLL_OUT);
    }

    \
     
     \ /
      Last update: 2022-06-23 20:09    [W:4.152 / U:0.028 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site