public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: fix missing sigmask restore in io_cqring_wait()
@ 2021-09-14 14:38 Xiaoguang Wang
  2021-09-14 14:47 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Xiaoguang Wang @ 2021-09-14 14:38 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, asml.silence, Xiaoguang Wang

Move get_timespec() section in io_cqring_wait() before the sigmask
saving, otherwise we'll fail to restore sigmask once get_timespec()
returns error.

Signed-off-by: Xiaoguang Wang <[email protected]>
---
 fs/io_uring.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 30d959416eba..1294b1ef4acb 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7310,6 +7310,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())
@@ -7323,14 +7331,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);
-	}
-
 	init_waitqueue_func_entry(&iowq.wq, io_wake_function);
 	iowq.wq.private = current;
 	INIT_LIST_HEAD(&iowq.wq.entry);
-- 
2.14.4.44.g2045bb6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring: fix missing sigmask restore in io_cqring_wait()
  2021-09-14 14:38 [PATCH] io_uring: fix missing sigmask restore in io_cqring_wait() Xiaoguang Wang
@ 2021-09-14 14:47 ` Jens Axboe
  2021-09-14 14:53   ` Xiaoguang Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2021-09-14 14:47 UTC (permalink / raw)
  To: Xiaoguang Wang, io-uring; +Cc: asml.silence

On 9/14/21 8:38 AM, Xiaoguang Wang wrote:
> Move get_timespec() section in io_cqring_wait() before the sigmask
> saving, otherwise we'll fail to restore sigmask once get_timespec()
> returns error.

Applied, thanks! I added a:

Fixes: c73ebb685fb6 ("io_uring: add timeout support for io_uring_enter()")

to the commit since that's when it got broken, that'll help with
stable backports. Not that it's a _huge_ issue, it basically means
the application is broken anyway.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring: fix missing sigmask restore in io_cqring_wait()
  2021-09-14 14:47 ` Jens Axboe
@ 2021-09-14 14:53   ` Xiaoguang Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Xiaoguang Wang @ 2021-09-14 14:53 UTC (permalink / raw)
  To: Jens Axboe, io-uring; +Cc: asml.silence

hi,


> On 9/14/21 8:38 AM, Xiaoguang Wang wrote:
>> Move get_timespec() section in io_cqring_wait() before the sigmask
>> saving, otherwise we'll fail to restore sigmask once get_timespec()
>> returns error.
> Applied, thanks! I added a:
>
> Fixes: c73ebb685fb6 ("io_uring: add timeout support for io_uring_enter()")
>
> to the commit since that's when it got broken, that'll help with
> stable backports. Not that it's a _huge_ issue, it basically means
> the application is broken anyway.

Agree, thanks.


Regards,

Xiaoguang Wang


>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-14 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-14 14:38 [PATCH] io_uring: fix missing sigmask restore in io_cqring_wait() Xiaoguang Wang
2021-09-14 14:47 ` Jens Axboe
2021-09-14 14:53   ` Xiaoguang Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox