* [PATCH bpf] bpf: Fix stale skb->csum in bpf_redirect_neigh()
@ 2026-12-04 10:28 Jiayuan Chen
2026-12-04 13:02 ` Nathan Malo
0 siblings, 1 reply; 2+ messages in thread
From: Jiayuan Chen @ 2026-12-04 10:28 UTC (permalink / raw)
To: bpf
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
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH bpf] bpf: Fix stale skb->csum in bpf_redirect_neigh()
2026-12-04 10:28 [PATCH bpf] bpf: Fix stale skb->csum in bpf_redirect_neigh() Jiayuan Chen
@ 2026-12-04 13:02 ` Nathan Malo
0 siblings, 0 replies; 2+ messages in thread
From: Nathan Malo @ 2026-12-04 13:02 UTC (permalink / raw)
To: jiayuan.chen@linux.dev
Cc: 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, bpf@vger.kernel.org
On Fri, 4 Dec 2026 at 11:28, Jiayuan Chen wrote:
> 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().
Thanks for the fix.
Tested on vanilla 6.18.64 with the reproducer from my report (mlx5,
tc ingress bpf_redirect_neigh() to a veth): the "hw csum failure"
no longer shows up on the veth peer.
Tested-by: Nathan Malo <nathan.malo@ovhcloud.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 13:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 10:28 [PATCH bpf] bpf: Fix stale skb->csum in bpf_redirect_neigh() Jiayuan Chen
2026-12-04 13:02 ` Nathan Malo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox