Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring: fix filename leak in __io_openat_prep()

__io_openat_prep() allocates a struct filename using getname(). However,
for the condition of the file being installed in the fixed file table as
well as having O_CLOEXEC flag set, the function returns early. At that
point, the request doesn't have REQ_F_NEED_CLEANUP flag set. Due to this,
the memory for the newly allocated struct filename is not cleaned up,
causing a memory leak.

Fix this by setting the REQ_F_NEED_CLEANUP for the request just after the
successful getname() call, so that when the request is torn down, the
filename will be cleaned up, along with other resources needing cleanup.

Reported-by: syzbot+00e61c43eb5e4740438f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=00e61c43eb5e4740438f
Tested-by: syzbot+00e61c43eb5e4740438f@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Prithvi Tambewagh <activprithvi@gmail.com>
Fixes: b9445598d8c6 ("io_uring: openat directly into fixed fd table")
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Prithvi Tambewagh and committed by
Jens Axboe
b14fad55 114ea9bb

+1 -1
+1 -1
io_uring/openclose.c
··· 73 73 open->filename = NULL; 74 74 return ret; 75 75 } 76 + req->flags |= REQ_F_NEED_CLEANUP; 76 77 77 78 open->file_slot = READ_ONCE(sqe->file_index); 78 79 if (open->file_slot && (open->how.flags & O_CLOEXEC)) 79 80 return -EINVAL; 80 81 81 82 open->nofile = rlimit(RLIMIT_NOFILE); 82 - req->flags |= REQ_F_NEED_CLEANUP; 83 83 if (io_openat_force_async(open)) 84 84 req->flags |= REQ_F_FORCE_ASYNC; 85 85 return 0;