Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring: use size_add helpers for ring offsets

Use size_add / size_mul set of functions for rings_size() calculations.
It's more consistent with struct_size(), and errors are preserved across
a series of calculations, so intermediate result checks can be omitted.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
94cd8329 e279bb4b

+8 -10
+8 -10
io_uring/io_uring.c
··· 2765 2765 2766 2766 *sq_offset = SIZE_MAX; 2767 2767 2768 - off = struct_size(rings, cqes, cq_entries); 2769 - if (off == SIZE_MAX) 2770 - return SIZE_MAX; 2771 - if (flags & IORING_SETUP_CQE32) { 2772 - if (check_shl_overflow(off, 1, &off)) 2773 - return SIZE_MAX; 2774 - } 2775 2768 if (flags & IORING_SETUP_CQE_MIXED) { 2776 2769 if (cq_entries < 2) 2777 2770 return SIZE_MAX; ··· 2773 2780 if (sq_entries < 2) 2774 2781 return SIZE_MAX; 2775 2782 } 2783 + 2784 + off = struct_size(rings, cqes, cq_entries); 2785 + if (flags & IORING_SETUP_CQE32) 2786 + off = size_mul(off, 2); 2787 + if (off == SIZE_MAX) 2788 + return SIZE_MAX; 2776 2789 2777 2790 #ifdef CONFIG_SMP 2778 2791 off = ALIGN(off, SMP_CACHE_BYTES); ··· 2792 2793 *sq_offset = off; 2793 2794 2794 2795 sq_array_size = array_size(sizeof(u32), sq_entries); 2795 - if (sq_array_size == SIZE_MAX) 2796 - return SIZE_MAX; 2797 - if (check_add_overflow(off, sq_array_size, &off)) 2796 + off = size_add(off, sq_array_size); 2797 + if (off == SIZE_MAX) 2798 2798 return SIZE_MAX; 2799 2799 } 2800 2800