diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2024-08-24 07:45:08 +0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2024-08-24 07:45:08 +0800 |
| commit | 489270f44c3fc2fb8d0e5d102ea08a90e93ca135 (patch) | |
| tree | 698f1a778506c2f591492d51c89a1aea0fd61c04 | |
| parent | b09f6ca99c46e4a561ac943253aca9beae8c1146 (diff) | |
| parent | e0ee967630c8ee67bb47a5b38d235cd5a8789c48 (diff) | |
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
| -rw-r--r-- | io_uring/kbuf.c | 9 |
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; } |
