]> www.infradead.org Git - users/willy/pagecache.git/commit
io_uring/kbuf: use pre-committed buffer address for non-pollable file
authorJens Axboe <axboe@kernel.dk>
Fri, 3 Jan 2025 16:29:09 +0000 (09:29 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 3 Jan 2025 16:38:37 +0000 (09:38 -0700)
commited123c948d06688d10f3b10a7bce1d6fbfd1ed07
treef301561101f81b7334cfe4f201d72128fb7f8fc3
parentc6e60a0a68b7e6b3c7e33863a16e8e88ba9eee6f
io_uring/kbuf: use pre-committed buffer address for non-pollable file

For non-pollable files, buffer ring consumption will commit upfront.
This is fine, but io_ring_buffer_select() will return the address of the
buffer after having committed it. For incrementally consumed buffers,
this is incorrect as it will modify the buffer address.

Store the pre-committed value and return that. If that isn't done, then
the initial part of the buffer is not used and the application will
correctly assume the content arrived at the start of the userspace
buffer, but the kernel will have put it later in the buffer. Or it can
cause a spurious -EFAULT returned in the CQE, depending on the buffer
size. As bounds are suitably checked for doing the actual IO, no adverse
side effects are possible - it's just a data misplacement within the
existing buffer.

Reported-by: Gwendal Fernet <gwendalfernet@gmail.com>
Cc: stable@vger.kernel.org
Fixes: ae98dbf43d75 ("io_uring/kbuf: add support for incremental buffer consumption")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/kbuf.c