Re: [PATCH stable 1/3] random: restore O_NONBLOCK support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 13, 2022 at 06:20:10PM +0200, Greg KH wrote:
> On Thu, Oct 13, 2022 at 09:36:52AM -0600, Jason A. Donenfeld wrote:
> > commit cd4f24ae9404fd31fc461066e57889be3b68641b upstream.
> > 
> > Prior to 5.6, when /dev/random was opened with O_NONBLOCK, it would
> > return -EAGAIN if there was no entropy. When the pools were unified in
> > 5.6, this was lost. The post 5.6 behavior of blocking until the pool is
> > initialized, and ignoring O_NONBLOCK in the process, went unnoticed,
> > with no reports about the regression received for two and a half years.
> > However, eventually this indeed did break somebody's userspace.
> > 
> > So we restore the old behavior, by returning -EAGAIN if the pool is not
> > initialized. Unlike the old /dev/random, this can only occur during
> > early boot, after which it never blocks again.
> > 
> > In order to make this O_NONBLOCK behavior consistent with other
> > expectations, also respect users reading with preadv2(RWF_NOWAIT) and
> > similar.
> > 
> > Fixes: 30c08efec888 ("random: make /dev/random be almost like /dev/urandom")
> > Reported-by: Guozihua <guozihua@xxxxxxxxxx>
> > Reported-by: Zhongguohua <zhongguohua1@xxxxxxxxxx>
> > Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> > Cc: Theodore Ts'o <tytso@xxxxxxx>
> > Cc: Andrew Lutomirski <luto@xxxxxxxxxx>
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Jason A. Donenfeld <Jason@xxxxxxxxx>
> > ---
> >  drivers/char/mem.c    | 4 ++--
> >  drivers/char/random.c | 5 +++++
> >  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> Still breaks on older kernels:
> 
> drivers/char/random.c: In function ‘random_read_iter’:
> drivers/char/random.c:1299:33: error: ‘IOCB_NOWAIT’ undeclared (first use in this function); did you mean ‘IPC_NOWAIT’?
>  1299 |             ((kiocb->ki_flags & IOCB_NOWAIT) ||
>       |                                 ^~~~~~~~~~~
>       |                                 IPC_NOWAIT
> drivers/char/random.c:1299:33: note: each undeclared identifier is reported only once for each function it appears in
> drivers/char/mem.c:872:48: error: ‘FMODE_NOWAIT’ undeclared here (not in a function); did you mean ‘FOLL_NOWAIT’?
>   872 |          [8] = { "random", 0666, &random_fops, FMODE_NOWAIT },
>       |                                                ^~~~~~~~~~~~
>       |                                                FOLL_NOWAIT
> 

Hm, that's only broken on 4.9, the other ones it worked, now queued up
for 4.14, 4.19, and 5.4, thanks.

greg k-h



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux