]> git.itanic.dy.fi Git - linux-stable/commit
io_uring: Fix release of pinned pages when __io_uaddr_map fails
authorGabriel Krisman Bertazi <krisman@suse.de>
Wed, 13 Mar 2024 21:39:12 +0000 (17:39 -0400)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:17:32 +0000 (18:17 -0400)
commit4d376d7ad62b6a8e8dfff56b559d9d275e5b9b3a
tree23f783d1c9ce3147b3cf2ea4eeef00aca859b652
parent552f799d02b6e50d1230a6b57a23f65c09e21e7e
io_uring: Fix release of pinned pages when __io_uaddr_map fails

[ Upstream commit 67d1189d1095d471ed7fa426c7e384a7140a5dd7 ]

Looking at the error path of __io_uaddr_map, if we fail after pinning
the pages for any reasons, ret will be set to -EINVAL and the error
handler won't properly release the pinned pages.

I didn't manage to trigger it without forcing a failure, but it can
happen in real life when memory is heavily fragmented.

Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
Fixes: 223ef4743164 ("io_uring: don't allow IORING_SETUP_NO_MMAP rings on highmem pages")
Link: https://lore.kernel.org/r/20240313213912.1920-1-krisman@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
io_uring/io_uring.c