[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHmME9pW6heXtPrfCP7J6ODgSc8sotsv6E3dnJoVBaPi+Ph=HA@mail.gmail.com>
Date: Tue, 5 Apr 2022 20:07:27 +0200
From: "Jason A. Donenfeld" <Jason@...c4.com>
To: Jann Horn <jannh@...gle.com>
Cc: "Theodore Ts'o" <tytso@....edu>,
LKML <linux-kernel@...r.kernel.org>,
Sebastian Siewior <bigeasy@...utronix.de>,
Thomas Gleixner <tglx@...utronix.de>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH] random: Fix signal_pending() usage
Hi Jann,
On Tue, Apr 5, 2022 at 6:39 PM Jann Horn <jannh@...gle.com> wrote:
> signal_pending() checks TIF_NOTIFY_SIGNAL and TIF_SIGPENDING, which signal
> that the task should bail out of the syscall when possible.
> This is a separate concept from need_resched(), which checks
> TIF_NEED_RESCHED, signalling that the task should preempt.
>
> In particular, with the current code, the signal_pending() bailout probably
> won't work reliably.
>
> Change this to look like other functions that read lots of data, such as
> read_zero().
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Applied, thanks.
One funny aspect of the fact that signal_pending() hasn't worked right
since the genesis commit is that this has probably led to a lot of
userspace code that doesn't check the result from read() or
getrandom(), and that code has worked mostly fine.
I wonder if we should do something about that. Worth noting is that
we're no longer contending with /dev/random periodically blocking as
the "entropy runs out" nonsense. I can think of two possible changes,
which maybe aren't mutually exclusive:
1) Turn signal_pending() into fatal_signal_pending() throughout the file.
2) Rather than not checking signal_pending() for reads of length <=
256, we could not check for signal_pending() for the first 256 bytes
of any length read.
Both of these would be changing userspace behavior, so it should
probably be considered carefully. Any thoughts?
Jason
Powered by blists - more mailing lists