Skip to content

Commit 09cfd3c

Browse files
isilenceaxboe
authored andcommitted
io_uring/zcrx: fix overshooting recv limit
It's reported that sometimes a zcrx request can receive more than was requested. It's caused by io_zcrx_recv_skb() adjusting desc->count for all received buffers including frag lists, but then doing recursive calls to process frag list skbs, which leads to desc->count double accounting and underflow. Reported-and-tested-by: Matthias Jasny <[email protected]> Fixes: 6699ec9 ("io_uring/zcrx: add a read limit to recvzc requests") Cc: [email protected] Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent beb9799 commit 09cfd3c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

io_uring/zcrx.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,12 +1236,16 @@ io_zcrx_recv_skb(read_descriptor_t *desc, struct sk_buff *skb,
12361236

12371237
end = start + frag_iter->len;
12381238
if (offset < end) {
1239+
size_t count;
1240+
12391241
copy = end - offset;
12401242
if (copy > len)
12411243
copy = len;
12421244

12431245
off = offset - start;
1246+
count = desc->count;
12441247
ret = io_zcrx_recv_skb(desc, frag_iter, off, copy);
1248+
desc->count = count;
12451249
if (ret < 0)
12461250
goto out;
12471251

0 commit comments

Comments
 (0)