diff options
author | Jiufei Xue <[email protected]> | 2020-09-02 17:59:39 +0800 |
---|---|---|
committer | Jens Axboe <[email protected]> | 2020-09-02 09:11:59 -0600 |
commit | 95d1c8e5f801e959a89181a2548a3efa60a1a6ce (patch) | |
tree | 9bd1f1f50996bbb5518c58605a473150f41eda2c | |
parent | 98dfd5024a2e9e170b85c07078e2d89f20a5dfbd (diff) |
io_uring: set table->files[i] to NULL when io_sqe_file_register failed
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.
Cc: [email protected]
Fixes: f3bd9dae3708 ("io_uring: fix memleak in __io_sqe_files_update()")
Signed-off-by: Jiufei Xue <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
-rw-r--r-- | fs/io_uring.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index a06b56289039..b1ccd7072d93 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; } |