From 7bc21b740291c06b6437fd7ed7fab2d707b35cff Mon Sep 17 00:00:00 2001 From: Narcisa Vasile Date: Tue, 15 Sep 2026 18:00:29 -0700 Subject: [PATCH] selftests: net: gro: fix OOB access when under-coalescing When more packets than expected are received, num_pkt could index beyond the end of the array. Add a check to prevent OOB access. Continue receiving until the FIN is received to obtain the total packet count. This helps diagnose issues by distinguishing the cases where no coalescing happened from the partial-coalescing cases that didn't meet the test check. Signed-off-by: Narcisa Vasile Link: https://patch.msgid.link/20260916010029.50911-1-narcisav.kernel@gmail.com Signed-off-by: Jakub Kicinski --- tools/testing/selftests/net/lib/gro.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/lib/gro.c b/tools/testing/selftests/net/lib/gro.c index 70b0deb3c11f..fb6a72275636 100644 --- a/tools/testing/selftests/net/lib/gro.c +++ b/tools/testing/selftests/net/lib/gro.c @@ -1303,7 +1303,8 @@ static void check_recv_pkts(int fd, int *correct_payload, - sizeof(struct tcphdr) - sizeof(struct iphdr); } vlog("%d ", data_len); - if (data_len != correct_payload[num_pkt]) { + if (num_pkt < correct_num_pkts && + data_len != correct_payload[num_pkt]) { vlog("[!=%d]", correct_payload[num_pkt]); bad_packet = true; }