πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10614

[PATCH net 2/3] selftests: net: tuntap: fix UDP checksum length in build_udp_packet_csum()

#10614
From: Eric Dumazet
Date: Tue, 03 Nov 2026 20:31
31 lines
8890 bytes
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>
---
 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);
 }
-- 
2.53.0
Technical Details
Message-ID: <20261103203113.550604-3-edumazet@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355948-linux-kernel-netdev=dewy.ru
References: <20261103203113.550604-1-edumazet@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355948-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 2/3] selftests: net: tuntap: fix UDP checksum length in build_udp_packet_csum()
Date: Tue,  3 Nov 2026 21:31:12 +0100
Organization: Usenet Network
Message-ID: <20261103203113.550604-3-edumazet@kernel.org>
References: <20261103203113.550604-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3254703"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:YuVNFhRpspz5eAfPcWA/obxZVxk= sha256:J9JYGx0bOHSyCxLcq5rbOI1i2fS0FMnNBlegtduUQWo=
	sha1:2FmDQZjqInR93mDcMGsaSiAWnek= sha256:JdoJ548kc2reW2iKCQokz7vE55B91w9POI/6us/B+lc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 03EE11129F2; Tue,  3 Nov 2026 23:31:57 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 3b08kW9Ipb5o;
	Tue,  3 Nov 2026 23:31:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-355948-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 206CC112031; Tue,  3 Nov 2026 23:31:40 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 3A9DC27165; Tue,  3 Nov 2026 20:31:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793737890;
	b=cst1m8j/wGjaj3PqR1BZc7/5rpg2QfzbD8Tx8uWyUcraCArS/O85MXvQomyRgEUAKTJp
	 DrTWjwjoybRsbA0xcOxqZKmbzctuwBBwfBGYy0AtL112gsXOIyZ12wrJ53pUTJB0D3uDG
	 dEuYJdteglPcnf7Q5tBTAS5L1GE3yt3Gw/Efv8aH/MHB+AKH9e2P1LkDlrYAsMjUVGE2i
	 NXzDbY6mRXXoRYkP5py7xgDG2h8s9VXa31AMmKLdzVi0IW/x5Bz7VzWB4lHMa8I/llRpz
	 q+VYM/XUKY0hziLn0RqnTBssf5UNeAVhbkBV5rq7rv1Ce/Ufoazs+ew9mNPt+Or3qlA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793737890;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=VFNRxIvcxkzTqlqpdT20AbjU9YSCGoaOHPbKbT6QSgE=;
	b=LoygMtEsNlfwDmSyocprmY5d+aahZyVDt7UjTRuwX6jBmJMcfeGJ3XEmdTFYAkIre9xU
	 I+IpHTDwU/TtbMDpQ1VDJ6RU5NWFXHZ3U2Yv6aIC2inldKpcjYaBDv3RrsAQSsfVd/Lyp
	 LQw6+0LrGwQTqgXxy3EDEwXQzQ0Yctyv4IZlU00uZUy87Ah2AsTrcNTncby6D/4+QO/RB
	 OQL0FnSx9NYhVCBC1bvTn6ZR0mDvWQ+i5Y4QRMGcjTp9l94D1UMoD0r8AjhnVBkVBxzAg
	 r9RHCD/JNh2swMPt02ZDozzoEiwAQ4OxwGOooUMiVcHC7vTOU/G+eiq6f76V1S4qiqw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hPc8eIjS;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 92EB8606A32D;
	Tue,  3 Nov 2026 20:31:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hPc8eIjS
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793737889;
	b=GjR/nr3kor1DitOeIQu4dRCssLUJrCh7QZGrNlcPsCn8ibGjLPoMtOrDigiy4j4xBTFe
	 1st4Dx+Zm3ccTEvHOOvOHiC4fKnOIi1F5mE1CZlZBILLbmNx8/SEUx7z1sIcR0mOBVAvG
	 x8Sjy+48GAkeZIweKIxnPLj89Kez0pJG56tptr9KnbKtY+syQXhOyp45bR28ebQvahXed
	 lgYNefk2ACNkEDkiGUVbp3sdpKI07kAowCPBxwBL2tWAAC9t2x08iSeBCCGKPTTi0BvHn
	 VRu17h9lhwMe0gbdOKTkPI+bjyW8Q9qHZP+3BSzRqSfmK4gOuCg4l+Kuc6RxAUgn7SA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793737889;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=VFNRxIvcxkzTqlqpdT20AbjU9YSCGoaOHPbKbT6QSgE=;
	b=WWar4zF/C53iMsFr2K5P3fHp9f2Pz8FJ2bIta3OoACWpylJfupZ83NfunYC74H8F0nZW
	 35aWhPJSOAg9S2RiUS4oIrwt7X59lhPi2vCB2bDhOvLoB+jeiBUasW1M65oyhgi03Jjo8
	 RffPqHZW9YKj8arTB/odgoeuM8hJ7R3q4v+UfKOQw5V8arcNGIo10eZPchqsAsIp3Le8Y
	 UIpceW1UU/t7N45Q+SRwQQIaV8iUKkklOsz6neyunfKwW2XosphIq5U71wKKL2A0VOVgA
	 59zaH7cz1sQp83anp0nzS3TOqi5XE8PyTSSvkNndFtxajydNNPpE7uCIJf5JZvY5FnA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hPc8eIjS;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7727A606A331;
	Tue,  3 Nov 2026 20:31:29 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8BB11F000C1;
	Tue,  3 Nov 2026 20:31:26 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793737889;
	bh=VFNRxIvcxkzTqlqpdT20AbjU9YSCGoaOHPbKbT6QSgE=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=hPc8eIjSs8DSwNmTu/eaY8bIQPDvXy8te5In0lRkRse+crCdxEOhxrVSMHboloY2R
	 thf6fTyKQpmv757GJi+4yYewIeWtbyysnTB+6LSkJCuiDHKOQ1W8yCYXa0exigtSVO
	 wc/kDV08At7WilUaflEQQs7ytN/12CqjhUbsL6MvSGUHbJTpAulwnzAnVR7gI/1bsR
	 Qw5lTTB2QygCdtffCHva7zH/olKsaaIeWwNqlpNZDjWzzmzZoQCPpybyGE4jYji8Ca
	 EOOLpvqhuoqZfRDsZk/OsnUjg9t9GDG408qisIgFmtHVIHj2/29A8PSIznA7IENktX
	 63bJuykqiLYNw==
X-Cc: Eric Dumazet <edumazet@kernel.org>,
	Simon Horman <horms@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Eugenio PΓ©rez <eperezma@redhat.com>,
	Hassan Sultan <hassansultan@google.com>,
	virtualization@lists.linux.dev
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261103203113.550604-1-edumazet@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list