🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26869

[PATCH bpf] bpf: Fix stale skb->csum in bpf_redirect_neigh()

#26869
From: Jiayuan Chen
Date: Fri, 04 Dec 2026 10:28
84 lines
11872 bytes
Nathan Malo reported a "hw csum failure" splat on a veth peer when a
tc ingress program redirects packets from a NIC with
bpf_redirect_neigh().

A CHECKSUM_COMPLETE skb carries the checksum of the whole packet in
skb->csum, as computed by the NIC. When such a skb is redirected with
bpf_redirect_neigh() from tc ingress, skb->csum ends up wrong:

- __bpf_redirect_neigh() calls bpf_push_mac_rcsum(), which adds the
  received L2 header to skb->csum, and then drops that header with a
  plain skb_pull(), so it is never subtracted again.

- neigh_output() then pushes the new L2 header without adding it to
  skb->csum.

The packet itself is fine, only skb->csum no longer matches it. This
is a transmit path and nobody validates a packet against skb->csum
there, so nothing notices as long as the target is a real NIC.

A veth target is different, the skb is received by the peer as is,
still marked CHECKSUM_COMPLETE. The peer then validates the packet
against the stale skb->csum:

  v1: hw csum failure
  csum(0x401e814 start=59412 offset=1025 ip_summed=2 complete_sw=0 valid=0 level=0)
  Call Trace:
   <IRQ>
   dump_stack_lvl+0xc1/0xf0
   dump_stack+0x10/0x20
   netdev_rx_csum_fault+0x6c/0x80
   __skb_checksum_complete+0x285/0x2f0
   udp_rcv+0x125b/0x2e80
   ip_protocol_deliver_rcu+0x23b/0x4a0
   ip_local_deliver_finish+0x369/0x5c0
   ip_local_deliver+0x165/0x1d0
   ip_rcv+0x284/0x320
   __netif_receive_skb_one_core+0x16b/0x1c0
   __netif_receive_skb+0x21/0x150
   process_backlog+0x3ec/0x14d0
   __napi_poll.constprop.0+0xa5/0x5e0
   net_rx_action+0x4ed/0xeb0
   handle_softirqs+0x251/0xa70
   __do_softirq+0x10/0x18
   do_softirq.part.0+0xab/0x100
   </IRQ>

The NIC driver is not at fault here, the value is broken by
bpf_redirect_neigh().

Keeping skb->csum correct is not really an option, the new L2 header
is pushed deep inside neigh_output(). This is a forwarding path, so do
what ip_forward() does and call skb_forward_csum(). skb->csum is not
used after that, so drop the bpf_push_mac_rcsum() call as well.

Fixes: b4ab31414970 ("bpf: Add redirect_neigh helper as redirect drop-in")
Reported-by: Nathan Malo <nathan.malo@ovhcloud.com>
Closes: https://lore.kernel.org/netdev/F6F168C5-A1C7-4029-90D3-CD402BC11E33@corp.ovh.com/
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
 net/core/filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 7f90099ae99c..992dc5c6b594 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2469,13 +2469,13 @@ static int __bpf_redirect_neigh(struct sk_buff *skb, struct net_device *dev,
 	if (unlikely(skb_network_offset(skb) < ETH_HLEN ||
 		     !pskb_may_pull(skb, ETH_HLEN)))
 		goto out;
-	bpf_push_mac_rcsum(skb);
 	if (is_multicast_ether_addr(eth_hdr(skb)->h_dest))
 		goto out;
 
 	skb_pull(skb, ETH_HLEN);
 	skb_unset_mac_header(skb);
 	skb_reset_network_header(skb);
+	skb_forward_csum(skb);
 
 	if (skb->protocol == htons(ETH_P_IP))
 		return __bpf_redirect_neigh_v4(skb, dev, nh);
-- 
2.43.0
Technical Details
Message-ID: <20261204102812.36739-1-jiayuan.chen@linux.dev>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377247-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377247-linux-kernel-netdev=dewy.ru
From: jiayuan.chen@linux.dev (Jiayuan Chen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH bpf] bpf: Fix stale skb->csum in bpf_redirect_neigh()
Date: Fri,  4 Dec 2026 18:28:11 +0800
Organization: Usenet Network
Message-ID: <20261204102812.36739-1-jiayuan.chen@linux.dev>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2738873"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:vys03v48VeBomk8VLs5Nb6aVioo= sha256:BkXn14g+Mr4XJqpHYPMUq2c2CIEeelMeqwqtAPk1pMU=
	sha1:dSMRdGnBY4NHypuXK5QFUNxVE7g= sha256:MWdJy5RxthCGtljRLtZ3KGbFsJ0S7izb1LEsDojKzXs=
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 AAA21117B9F; Fri,  4 Dec 2026 13:28:59 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.299
X-Spam-Status: No, score=-2.299 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
	HK_RANDOM_FROM=0.999, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,
	SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
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 u5rYmI9uW1o6;
	Fri,  4 Dec 2026 13:28:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377247-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 968A5117B52; Fri,  4 Dec 2026 13:28:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 805EE2AC73; Fri,  4 Dec 2026 10:28:36 +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=1796380116;
	b=lfdVM2+6/1gAgh2wiWH32mRdpAMZ4ZkIvSt6NGmB428T3GudvidNBxBhBCSo+9KQxlKz
	 PYSJ7HR8KvRtMj24QK3ZzcQG7PRjTs6huaDYjbsgP1VEYFtexwFVGiOl9vC1OFMaVURn6
	 Yi2H4N4lPf92P7AqTL0AH7iX0z+VOKXL5kP7bXtDv0pt+ZevTfP83qig5d+VjjZ03vdQ0
	 JUzCyTbodgiXiUH2NVhJ6nNdWFQ7pGD976vakb7gqI1T0lc6DR1gJwJHmdz0+zbXu25GW
	 YjQHLhU7nRdNlcpufCPhF971yKghjQW7y99yvp6VwAYYOzPtLFhbNhFsk+qeHQZD4qQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796380116;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Transfer-Encoding;
	bh=E8nNZ245+Ytk/bW0hUKGnJjVfRSEQDYUEfIer0DrdyM=;
	b=R3amuhTXQSp9hi/pvMFcqfg4w4V38ijTd8SsbbP6L3uxbpDUMhAqEFu3/GqMo/LCxvoe
	 WjES24kJlmOyiYsd/7OOHKXsSperdZrnkrSpjookxltoLrBe5ePJTxGvbRMe5+inhmyc/
	 tBMiU1IBZtvUhuxv16dedXbqtmpRmz1mFNSBj2CXNX5vxk8N/ecqf8eM5FabGKBZhKJsJ
	 ZwuDnv6Rmmp8gl1CBEZFU0fwEaQmubZ/L3gPzoazO8XH6IKDchWzFoDsbllBE6HzJFVhQ
	 5qwGHkJRVYMLAkoUH/9o23MsrNMozi8WhvCFQ1FsbJP1wx7o3iVON+b64yZdpPJcIzQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=cfR3hOFJ;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 36EC6606A32C;
	Fri,  4 Dec 2026 10:28:36 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=cfR3hOFJ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.111
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796380115;
	b=qPltsmQSuUQMWqHk7yq82HaJotJSS5W0i/U72yJTkQpdcCQ+/CIXQHF+tVJZ36h/TAFT
	 /KB9rVtVkKw0zHSRWJ8dhJoWLHAxEU29YsIFPZM0cNEfOn9eYigSNo9YzhP7yneGx1KxY
	 iV64Qm4xgbua+2RUBRLuE7src0BmO5Mmb9mR+2QvOBCUko59sRudjBK51pGqfDB9gXpDr
	 UTIm0Or+VS+77G5SbI0oAzxVxikD97rSzGWdRl8m/am3N/Lpe4c/uh1+/l2W5a3Biik6y
	 Ff4XmIzAlq+gnpLdvhzeF9sJm161ZKJlHEzji5DbQ7oU9PsM/KLyL9xYmvMgy6DNDjw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796380115;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:MIME-Version:Content-Transfer-Encoding;
	bh=E8nNZ245+Ytk/bW0hUKGnJjVfRSEQDYUEfIer0DrdyM=;
	b=rT+zhmJnRrNs/rS5+T0RUQiYDX4cIydWtzSGlZhN8xu9jUyEQmARZAZh6TXH91kZuDh6
	 wxy+F70YFEmElv8sl67UJ4cBDGLcywDF2TF0KtU07bzY01nmrVqWFv51I3I7r1PwjqLAI
	 bpQgi4zVL/8EahLD//BeJHL9ET3F3GfRIjzXgwhRJd5Nb1nYC4KtRpG673H9M/+Xm+e7t
	 Vs9aDGVi4f0YtMgOVDUzO/XnAhw6OYKzCUCSw7EOGr38Z5/5Nz3TGn9b+skHnOFw8UPAN
	 Ilb9x/EpvoFqDCGJlAhVzr51qKaoewGoDPMtjfO9qdcr09iS6Nni0lKfhvOPaiP1+Fw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=cfR3hOFJ;
	arc=none smtp.remote-ip=91.218.175.111
X-Received: from mta0.migadu.com (out-111.mta0.migadu.com [91.218.175.111])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85ED8606A32D
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 10:28:34 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 85ED8606A32D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=G4TrltV0ZTcvTGflhXX4oLB4xfM9VzMIxaT1BLW8L9I=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1796380112; v=1; x=1796984912;
 b=cfR3hOFJgvsIHO6+3rrEXpNGwRxMqG+tactanpPsERmHAw9ywjIeJCn8kxENj37T+ATVsGfU
 H9QV+dmGGAqhcMUVjO8Us3YyB9SRbAcjBxfUuw0DBuXSKPrjVxpaYMBF+o5CP8TmOlahWsZ1Rr1
 3tUt5+gGbIY+hnjkt/DiCbTg=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 5ac78806ef01ef47;
	Fri, 04 Dec 2026 10:28:32 +0000
X-Mizu-Trace-ID: 5ac78806ef01ef47
X-Migadu-Flow: FLOW_OUT
X-Cc: Jiayuan Chen <jiayuan.chen@linux.dev>,
	Nathan Malo <nathan.malo@ovhcloud.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	netdev@vger.kernel.org
X-Mailer: git-send-email 2.43.0
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