]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
io_uring: fix memory leak of UNIX domain socket inode
authorEric Biggers <ebiggers@google.com>
Wed, 12 Jun 2019 21:58:43 +0000 (14:58 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Jun 2019 09:00:30 +0000 (03:00 -0600)
commit355e8d26f719c207aa2e00e6f3cfab3acf21769b
tree4c9d87662a31867ec86c74582df7a62e1bc52d2d
parentb9aef63aca772a25ffcfaedf4bd29fb36b919a93
io_uring: fix memory leak of UNIX domain socket inode

Opening and closing an io_uring instance leaks a UNIX domain socket
inode.  This is because the ->file of the io_uring instance's internal
UNIX domain socket is set to point to the io_uring file, but then
sock_release() sees the non-NULL ->file and assumes the inode reference
is held by the file so doesn't call iput().  That's not the case here,
since the reference is still meant to be held by the socket; the actual
inode of the io_uring file is different.

Fix this leak by NULL-ing out ->file before releasing the socket.

Reported-by: syzbot+111cb28d9f583693aefa@syzkaller.appspotmail.com
Fixes: 2b188cc1bb85 ("Add io_uring IO interface")
Cc: <stable@vger.kernel.org> # v5.1+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c