Skip to content

Commit 1448769

Browse files
thejhzx2c4
authored andcommitted
random: check for signal_pending() outside of need_resched() check
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>
1 parent aba120c commit 1448769

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/char/random.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,13 @@ static ssize_t get_random_bytes_user(void __user *buf, size_t nbytes)
549549
}
550550

551551
do {
552-
if (large_request && need_resched()) {
552+
if (large_request) {
553553
if (signal_pending(current)) {
554554
if (!ret)
555555
ret = -ERESTARTSYS;
556556
break;
557557
}
558-
schedule();
558+
cond_resched();
559559
}
560560

561561
chacha20_block(chacha_state, output);

0 commit comments

Comments
 (0)