From: Pavel Begunkov Date: Tue, 21 Apr 2026 08:45:29 +0000 (+0100) Subject: io_uring/zcrx: warn on freelist violations X-Git-Tag: v7.0.9~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0b298b652e9a0b4b9a65c243cd0b6d6febc910e;p=thirdparty%2Fkernel%2Fstable.git io_uring/zcrx: warn on freelist violations commit 770594e78c3964cf23cf5287f849437cdde9b7d0 upstream. The freelist is appropriately sized to always be able to take a free niov, but let's be more defensive and check the invariant with a warning. That should help to catch any double-free issues. Suggested-by: Kai Aizen Signed-off-by: Pavel Begunkov Link: https://patch.msgid.link/2f3cea363b04649755e3b6bb9ab66485a95936d5.1776760901.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Harshit Mogalapalli Signed-off-by: Greg Kroah-Hartman --- diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c index 517b8ddb2cc2..4eb08c832f0b 100644 --- a/io_uring/zcrx.c +++ b/io_uring/zcrx.c @@ -587,6 +587,8 @@ static void io_zcrx_return_niov_freelist(struct net_iov *niov) struct io_zcrx_area *area = io_zcrx_iov_to_area(niov); guard(spinlock_bh)(&area->freelist_lock); + if (WARN_ON_ONCE(area->free_count >= area->nia.num_niovs)) + return; area->freelist[area->free_count++] = net_iov_idx(niov); }