public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: fix a use after free in io_async_task_func()
@ 2020-07-08 18:47 Dan Carpenter
  2020-07-08 19:01 ` Pavel Begunkov
  2020-07-08 19:15 ` Jens Axboe
  0 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2020-07-08 18:47 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Pavel Begunkov, linux-fsdevel, io-uring, kernel-janitors

The "apoll" variable is freed and then used on the next line.  We need
to move the free down a few lines.

Fixes: 0be0b0e33b0b ("io_uring: simplify io_async_task_func()")
Signed-off-by: Dan Carpenter <[email protected]>
---
 fs/io_uring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 70828e2470e2..f2993070a9e8 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -4652,12 +4652,13 @@ static void io_async_task_func(struct callback_head *cb)
 	/* restore ->work in case we need to retry again */
 	if (req->flags & REQ_F_WORK_INITIALIZED)
 		memcpy(&req->work, &apoll->work, sizeof(req->work));
-	kfree(apoll);
 
 	if (!READ_ONCE(apoll->poll.canceled))
 		__io_req_task_submit(req);
 	else
 		__io_req_task_cancel(req, -ECANCELED);
+
+	kfree(apoll);
 }
 
 static int io_async_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
-- 
2.27.0


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

end of thread, other threads:[~2020-07-09  9:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-08 18:47 [PATCH] io_uring: fix a use after free in io_async_task_func() Dan Carpenter
2020-07-08 19:01 ` Pavel Begunkov
2020-07-08 19:14   ` Jens Axboe
2020-07-08 19:15 ` Jens Axboe
2020-07-08 19:28   ` Pavel Begunkov
2020-07-08 19:56     ` Matthew Wilcox
2020-07-09  9:47       ` Pavel Begunkov

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