Skip to content

Commit

Permalink
io_uring: set table->files[i] to NULL when io_sqe_file_register failed
Browse files Browse the repository at this point in the history
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: stable@vger.kernel.org
Fixes: f3bd9da ("io_uring: fix memleak in __io_sqe_files_update()")
Signed-off-by: Jiufei Xue <jiufei.xue@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jiufei Xue authored and Jens Axboe committed Sep 2, 2020
1 parent 98dfd50 commit 95d1c8e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 95d1c8e

Please sign in to comment.