]> git.itanic.dy.fi Git - linux-stable/commit
io_uring: fix deferred req iovec leak
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 6 Feb 2020 16:51:16 +0000 (19:51 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Feb 2020 18:53:58 +0000 (19:53 +0100)
commit15307ec04eb362ce909bbffa679893e21fbf5453
tree52297bd1adc6b17bc8a6859732e2952b8916240e
parent3f29db9524f0e3f7338acc8b460b3940de7ab1eb
io_uring: fix deferred req iovec leak

commit 1e95081cb5b4cf77065d37866f57cf3c90a3df78 upstream.

After defer, a request will be prepared, that includes allocating iovec
if needed, and then submitted through io_wq_submit_work() but not custom
handler (e.g. io_rw_async()/io_sendrecv_async()). However, it'll leak
iovec, as it's in io-wq and the code goes as follows:

io_read() {
if (!io_wq_current_is_worker())
kfree(iovec);
}

Put all deallocation logic in io_{read,write,send,recv}(), which will
leave the memory, if going async with -EAGAIN.

It also fixes a leak after failed io_alloc_async_ctx() in
io_{recv,send}_msg().

Cc: stable@vger.kernel.org # 5.5
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c