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/zcrx: return early from io_zcrx_recv_skb if readlen is 0

When readlen is set for a recvzc request, tcp_read_sock() will call
io_zcrx_recv_skb() one final time with len == desc->count == 0. This is
caused by the !desc->count check happening too late. The offset + 1 !=
skb->len happens earlier and causes the while loop to continue.

Fix this in io_zcrx_recv_skb() instead of tcp_read_sock(). Return early
if len is 0 i.e. the read is done.

Fixes: 6699ec9a23f8 ("io_uring/zcrx: add a read limit to recvzc requests")
Signed-off-by: David Wei <dw@davidwei.uk>
Link: https://lore.kernel.org/r/20250401195355.1613813-1-dw@davidwei.uk
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

David Wei and committed by
Jens Axboe
fcfd94d6 81ed1801

+8
+8
io_uring/zcrx.c
··· 818 818 int ret = 0; 819 819 820 820 len = min_t(size_t, len, desc->count); 821 + /* 822 + * __tcp_read_sock() always calls io_zcrx_recv_skb one last time, even 823 + * if desc->count is already 0. This is caused by the if (offset + 1 != 824 + * skb->len) check. Return early in this case to break out of 825 + * __tcp_read_sock(). 826 + */ 827 + if (!len) 828 + return 0; 821 829 if (unlikely(args->nr_skbs++ > IO_SKBS_PER_CALL_LIMIT)) 822 830 return -EAGAIN; 823 831