]> git.itanic.dy.fi Git - linux-stable/commit
io_uring/kbuf: hold io_buffer_list reference over mmap
authorJens Axboe <axboe@kernel.dk>
Tue, 2 Apr 2024 22:16:03 +0000 (16:16 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:38:16 +0000 (16:38 +0200)
commit5fd8e2359498043e0b5329a05f02d10a9eb91eb9
tree5447814d036724a2b0749708e45c1e9e97e837ec
parente716bf33a07b5a4f22b77235ddebc08017e81e20
io_uring/kbuf: hold io_buffer_list reference over mmap

commit 561e4f9451d65fc2f7eef564e0064373e3019793 upstream.

If we look up the kbuf, ensure that it doesn't get unregistered until
after we're done with it. Since we're inside mmap, we cannot safely use
the io_uring lock. Rely on the fact that we can lookup the buffer list
under RCU now and grab a reference to it, preventing it from being
unregistered until we're done with it. The lookup returns the
io_buffer_list directly with it referenced.

Cc: stable@vger.kernel.org # v6.4+
Fixes: 5cf4f52e6d8a ("io_uring: free io_buffer_list entries via RCU")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/io_uring.c
io_uring/kbuf.c
io_uring/kbuf.h