random: check for signal_pending() outside of need_resched() check
authorJann Horn <jannh@google.com>
Tue, 5 Apr 2022 16:39:31 +0000 (18:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 30 May 2022 07:27:11 +0000 (09:27 +0200)
commit90fc9bf665b235e483a106fd377abe7eb1b1c651
tree4d055cfc8842dac187779e17498630699908df46
parentb8567f745fa64e96dd77b931f310804ae9c20370
random: check for signal_pending() outside of need_resched() check

commit 1448769c9cdb69ad65287f4f7ab58bc5f2f5d7ba upstream.

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, signaling 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")
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/random.c