This is a note to let you know that I've just added the patch titled io_uring: fix missing sigmask restore in io_cqring_wait() to the 5.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: io_uring-fix-missing-sigmask-restore-in-io_cqring_wa.patch and it can be found in the queue-5.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit f2187e52bdf453eabde353e2e942457abbff595d Author: Xiaoguang Wang <xiaoguang.wang@xxxxxxxxxxxxxxxxx> Date: Tue Sep 14 22:38:52 2021 +0800 io_uring: fix missing sigmask restore in io_cqring_wait() [ Upstream commit 44df58d441a94de40d52fca67dc60790daee4266 ] Move get_timespec() section in io_cqring_wait() before the sigmask saving, otherwise we'll fail to restore sigmask once get_timespec() returns error. Fixes: c73ebb685fb6 ("io_uring: add timeout support for io_uring_enter()") Signed-off-by: Xiaoguang Wang <xiaoguang.wang@xxxxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20210914143852.9663-1-xiaoguang.wang@xxxxxxxxxxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/fs/io_uring.c b/fs/io_uring.c index 0361c48c9cb0..dc5bba566f8b 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7088,6 +7088,14 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, break; } while (1); + if (uts) { + struct timespec64 ts; + + if (get_timespec64(&ts, uts)) + return -EFAULT; + timeout = timespec64_to_jiffies(&ts); + } + if (sig) { #ifdef CONFIG_COMPAT if (in_compat_syscall()) @@ -7101,14 +7109,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, return ret; } - if (uts) { - struct timespec64 ts; - - if (get_timespec64(&ts, uts)) - return -EFAULT; - timeout = timespec64_to_jiffies(&ts); - } - iowq.nr_timeouts = atomic_read(&ctx->cq_timeouts); trace_io_uring_cqring_wait(ctx, min_events); do {