summaryrefslogtreecommitdiff
path: root/io_uring/kbuf.h
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-04-03 01:16:03 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-04-10 17:38:16 +0300
commit5fd8e2359498043e0b5329a05f02d10a9eb91eb9 (patch)
tree5447814d036724a2b0749708e45c1e9e97e837ec /io_uring/kbuf.h
parente716bf33a07b5a4f22b77235ddebc08017e81e20 (diff)
downloadlinux-5fd8e2359498043e0b5329a05f02d10a9eb91eb9.tar.xz
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>
Diffstat (limited to 'io_uring/kbuf.h')
-rw-r--r--io_uring/kbuf.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/io_uring/kbuf.h b/io_uring/kbuf.h
index 55e1c888c3f9..038091a0047d 100644
--- a/io_uring/kbuf.h
+++ b/io_uring/kbuf.h
@@ -61,7 +61,9 @@ unsigned int __io_put_kbuf(struct io_kiocb *req, unsigned issue_flags);
bool io_kbuf_recycle_legacy(struct io_kiocb *req, unsigned issue_flags);
-void *io_pbuf_get_address(struct io_ring_ctx *ctx, unsigned long bgid);
+void io_put_bl(struct io_ring_ctx *ctx, struct io_buffer_list *bl);
+struct io_buffer_list *io_pbuf_get_bl(struct io_ring_ctx *ctx,
+ unsigned long bgid);
static inline bool io_kbuf_recycle_ring(struct io_kiocb *req)
{