Patch "io_uring/kbuf: sanitize peek buffer setup" has been added to the 6.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    io_uring/kbuf: sanitize peek buffer setup

to the 6.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     io_uring-kbuf-sanitize-peek-buffer-setup.patch
and it can be found in the queue-6.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 6513e8ece426ad00a0c34fe6b9d700d2cc930213
Author: Jens Axboe <axboe@xxxxxxxxx>
Date:   Tue Aug 20 18:31:58 2024 -0600

    io_uring/kbuf: sanitize peek buffer setup
    
    [ Upstream commit e0ee967630c8ee67bb47a5b38d235cd5a8789c48 ]
    
    Harden the buffer peeking a bit, by adding a sanity check for it having
    a valid size. Outside of that, arg->max_len is a size_t, though it's
    only ever set to a 32-bit value (as it's governed by MAX_RW_COUNT).
    Bump our needed check to a size_t so we know it fits. Finally, cap the
    calculated needed iov value to the PEEK_MAX_IMPORT, which is the
    maximum number of segments that should be peeked.
    
    Fixes: 35c8711c8fc4 ("io_uring/kbuf: add helpers for getting/peeking multiple buffers")
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c
index c95dc1736dd93..1af2bd56af44a 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;
 	}




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux