From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.105 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380115; b=zimqeqMEbzagICEm3hKh5e2YkNu5ImoC/tzN62UYIkoTeaRW7VAyC6wRrebeUEcQAPi1 dkSCyiJp8kdaI+Ud/neeUFnzZyZ+l4fJDSw9CvdcorCP6sANrOdyjpxeRA9sVHzNMug+S +MyMxK8Yo7w/JDY7TC+9ku5hT63X/MtMMWjtgfjA6qGa6HF5IaA8gFqjA/PhLPyRQZZYX 46jiflFqvLd1S/eOFJ2W0fVqa4XjZhWbpJ7lfCUhS1Ph0qSYK0HsYewxtM58ta4qBMwAX 10W0bDufLBIu72fRxExhL6KTbp766k7ac7YfIIIkfryaF/ouQDYlKtu8a4PXjbkP9lw== 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=uQfSxjI1lVRE68RyJGukb0qYsPnazouMIAl7/pV7M3SzcF1KyZtzk8U/qnuhfzZuv69A tJv/YGGigVTGd6mhOW0bnK3D2Qv8YfGbk+3fS4p00D+0cOHIu7aryMjoU9D9kDDEg5omp fpTsxVAIrB+r3GUWr2pks0EEh9MUdNt5S/ylAYku3eJsmJYi0GpT9Lws7zo9UPlYDOMpt JJuNFCqSqFdcMWiNErnQV/onyFdOXEBxVPQFfNJyvX2uc31d5LuVqXN37rpQgtza82Kq8 hnLtvU+qt9QBl1dFk55zy4xobRdQi8lSQzcWtfDKFd09Lo8dDeTc2ZkTwFYZ0/cEsoA== 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.105 Received: from mta0.migadu.com (out-105.mta0.migadu.com [91.218.175.105]) (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 6972A606A32F for ; Fri, 4 Dec 2026 10:28:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6972A606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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-Envelope-To: bpf@vger.kernel.org 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: bpf@vger.kernel.org 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 From: Jiayuan Chen To: bpf@vger.kernel.org Cc: Jiayuan Chen , Nathan Malo , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , John Fastabend , Stanislav Fomichev , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , David Ahern , netdev@vger.kernel.org Subject: [PATCH bpf] bpf: Fix stale skb->csum in bpf_redirect_neigh() Date: Fri, 4 Dec 2026 18:28:11 +0800 Message-ID: <20261204102812.36739-1-jiayuan.chen@linux.dev> X-Mailer: git-send-email 2.43.0 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 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 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 Closes: https://lore.kernel.org/netdev/F6F168C5-A1C7-4029-90D3-CD402BC11E33@corp.ovh.com/ Signed-off-by: Jiayuan Chen --- 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