Eric Dumazet wrote:
build_udp_packet_csum() passes udph->len, which is in network byte
order, as the number of bytes to checksum. On little-endian hosts this
reads up to 64KB past the UDP header and computes a wrong checksum.
Existing callers did not crash only because they use packet buffers
of MAX_VNET_TUNNEL_PACKET_SZ bytes.
Use ntohs(udph->len), as tap.c does in its own build_udp_packet().
Fixes: a942fcd72e97 ("selftest: tun: Introduce tuntap_helpers.h header for TUN/TAP testing")
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Willem de Bruijn <willemb@google.com>
quoted hunk ↗ jump to hunk
---
tools/testing/selftests/net/tuntap_helpers.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/tuntap_helpers.h b/tools/testing/selftests/net/tuntap_helpers.h
index d6c0437136ec..ac9b2da57a6d 100644
--- a/tools/testing/selftests/net/tuntap_helpers.h
+++ b/tools/testing/selftests/net/tuntap_helpers.h
@@ -335,7 +335,7 @@ static inline void build_udp_packet_csum(uint8_t *buf, int family,
sum += htons(IPPROTO_UDP) + udph->len;
if (!csum_off)
- sum += add_csum(buf, udph->len);
+ sum += add_csum(buf, ntohs(udph->len));
udph->check = finish_ip_csum(sum);
If respinning: we probably should also do CSUM_MANGLED_0 conversion here.
And to zero udph->check first. All existing callers do. But the calloc in
patch 3/3 does not.
}
--
2.53.0