public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: set table->files[i] to NULL when io_sqe_file_register failed
@ 2020-09-02  9:59 Jiufei Xue
  2020-09-02 14:12 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Jiufei Xue @ 2020-09-02  9:59 UTC (permalink / raw)
  To: io-uring, axboe

While io_sqe_file_register() failed in __io_sqe_files_update(),
table->files[i] still point to the original file which may freed
soon, and that will trigger use-after-free problems.

Signed-off-by: Jiufei Xue <[email protected]>
---
 fs/io_uring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index ce69bd9..0092418 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7353,6 +7353,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
 			table->files[index] = file;
 			err = io_sqe_file_register(ctx, file, i);
 			if (err) {
+				table->files[index] = NULL;
 				fput(file);
 				break;
 			}
-- 
1.8.3.1


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

end of thread, other threads:[~2020-09-02 15:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-02  9:59 [PATCH] io_uring: set table->files[i] to NULL when io_sqe_file_register failed Jiufei Xue
2020-09-02 14:12 ` Jens Axboe
2020-09-02 15:07   ` missing backport markings on security fix [was: [PATCH] io_uring: set table->files[i] to NULL when io_sqe_file_register failed] Jann Horn
2020-09-02 15:11     ` Jens Axboe

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