aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2024-08-24 07:45:08 +0800
committerLinus Torvalds <torvalds@linux-foundation.org>2024-08-24 07:45:08 +0800
commit489270f44c3fc2fb8d0e5d102ea08a90e93ca135 (patch)
tree698f1a778506c2f591492d51c89a1aea0fd61c04
parentMerge tag 'acpi-6.11-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm (diff)
parentio_uring/kbuf: sanitize peek buffer setup (diff)
downloadwireguard-linux-489270f44c3fc2fb8d0e5d102ea08a90e93ca135.tar.xz
wireguard-linux-489270f44c3fc2fb8d0e5d102ea08a90e93ca135.zip
Merge tag 'io_uring-6.11-20240823' of git://git.kernel.dk/linux
Pull io_uring fix from Jens Axboe: "Just a single fix for provided buffer validation" * tag 'io_uring-6.11-20240823' of git://git.kernel.dk/linux: io_uring/kbuf: sanitize peek buffer setup
Diffstat (limited to '')
-rw-r--r--io_uring/kbuf.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c
index c95dc1736dd9..1af2bd56af44 100644
--- a/io_uring/kbuf.c
+++ b/io_uring/kbuf.c
@@ -218,10 +218,13 @@ static int io_ring_buffers_peek(struct io_kiocb *req, struct buf_sel_arg *arg,
buf = io_ring_head_to_buf(br, head, bl->mask);
if (arg->max_len) {
- int needed;
+ u32 len = READ_ONCE(buf->len);
+ size_t needed;
- needed = (arg->max_len + buf->len - 1) / buf->len;
- needed = min(needed, PEEK_MAX_IMPORT);
+ if (unlikely(!len))
+ return -ENOBUFS;
+ needed = (arg->max_len + len - 1) / len;
+ needed = min_not_zero(needed, (size_t) PEEK_MAX_IMPORT);
if (nr_avail > needed)
nr_avail = needed;
}