summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorJann Horn <jannh@google.com>2022-04-05 18:39:31 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-25 11:46:37 +0200
commitcf8136b351692783036bc4eb0df85ebaf453d8b5 (patch)
tree15a49f0c5d98cf40db76e2576df74dae3481e3bd /drivers/char
parent04d681d81b7dfbfc5f33094914de96e2e047f22f (diff)
downloadlinux-stable-cf8136b351692783036bc4eb0df85ebaf453d8b5.tar.gz
linux-stable-cf8136b351692783036bc4eb0df85ebaf453d8b5.tar.bz2
linux-stable-cf8136b351692783036bc4eb0df85ebaf453d8b5.zip
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>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/random.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index cae0a6e5a9e9..a2e80bf9060f 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -549,13 +549,13 @@ static ssize_t get_random_bytes_user(void __user *buf, size_t nbytes)
}
do {
- if (large_request && need_resched()) {
+ if (large_request) {
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
break;
}
- schedule();
+ cond_resched();
}
chacha20_block(chacha_state, output);