summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorJiufei Xue <jiufei.xue@linux.alibaba.com>2020-09-02 12:59:39 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-09-09 20:14:29 +0300
commit329c9ffc81cfb985c6d131e94e6d220d7c1b19ca (patch)
tree25d723ac768be8e28260959d60d648f0025f2474 /fs
parenta7a42c1e5023cdac2bbc1038689509595d279cd2 (diff)
downloadlinux-329c9ffc81cfb985c6d131e94e6d220d7c1b19ca.tar.xz
io_uring: set table->files[i] to NULL when io_sqe_file_register failed
commit 95d1c8e5f801e959a89181a2548a3efa60a1a6ce upstream. 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: f3bd9dae3708 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/io_uring.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 4115bfedf15d..5f6fdb100aec 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6957,6 +6957,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;
}