From: sashiko-bot@kernel.org
To: "Jamal Hadi Salim" <jhs@mojatatu.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v5 2/3] net: neighbour: reinject a parked skb through a headerless output device
Date: Tue, 17 Nov 2026 10:36:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-218641@kernel.org> (raw)
In-Reply-To: <QDISC-6HS9.v5.r0.20261116052927-2@mojatatu.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] net: neighbour: reinjecting skb onto n1->dev misroutes
redirected packets
- [Low] net: neighbour: unresolvable commit SHA 1da177e4c3f4 in Fixes
trailer
--
commit c144e3e967eef24fc933621e8fea6beda200db16
Author: Jamal Hadi Salim <jhs@mojatatu.com>
> net: neighbour: reinject a parked skb through a headerless output device
>
> The issue:
> neigh_update_process_arp_queue() drains a neighbour's arp_queue and
> reinjects every skb through READ_ONCE(n1->output)(n1, skb), where n1 is
> the top-level neighbour re-looked-up from the skb's dst, not the neighbour
> the skb was queued on. skb->dev is whatever the producer left there.
> Note: skb->dev and n1->dev are not guaranteed to be equal.
>
> When n1->dev has no header_ops, arp_constructor() and ndisc_constructor()
> install neigh_direct_output(), a plain dev_queue_xmit() that transmits on
> skb->dev and builds no link header. Such an output sends the skb out
> whatever device skb->dev names, not out n1->dev, so a producer that
> parked the skb naming a lower device has it leave without the link header
> its own transmit path builds.
>
> sch_teql is the producer that hits this: it parks the skb on the slave's
> neighbour while the top-level neighbour is the master's, so skb->dev and
> n1->dev differ and the reinjection has to come back through the master to
> leave with a header. It names the slave on purpose, so that a parked skb
> does not outlive the master it came from.
>
> This half was split out of the sch_teql fix on review, so that the
> neighbour restore carries its own commit log and its own Cc set.
>
> The Fix:
> Put skb->dev back to n1->dev before the output call when that device
> builds no link header, so a headerless output transmits on the device the
> neighbour belongs to, whatever the producer left in skb->dev.
>
> A forward that steers the skb to another device, nft fwd ... neigh or
> bpf_redirect_neigh() with explicit nexthop parameters, parks it with the
> dst of the original route still attached. When the original route is
> itself a headerless device this gate matches there and the skb goes back
> out the original device, running its egress hook a second time. Those
> forwards supply their own device and nexthop and do not consult the
> retained dst, so dropping it at those two sites is where that is fixed;
> that is a separate change to the producers.
>
> Conditions to recreate the bug:
> CONFIG_NET_SCH_TEQL=m and CONFIG_VETH=y, run as root. This is the
> neighbour half of the sch_teql parked-skb fix, reached once sch_teql parks
> the skb naming the slave: create a veth pair, make one end a teql slave,
> give the master an address and a route, flush the slave's neighbour entry
> and send one packet:
>
> ip link add v0 type veth peer name v0p
> ip link set v0 up; ip link set v0p up
> tc qdisc add dev v0 root teql0
> ip link set teql0 up
> ip addr add 10.0.0.1/24 dev teql0
> ip route add 10.0.0.99/32 dev teql0
> ip neigh flush dev v0
> ping -I teql0 -c 1 10.0.0.99
>
> The packet parks on v0's arp_queue. When the solicitation resolves,
> neigh_update_process_arp_queue() reinjects it; without this change it
> leaves v0 directly, with no link header, and never reaches the peer.
>
> The window that frees the master, and the unload recipe that shows it,
> are in the sch_teql patch.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Link: https://lore.kernel.org/netdev/20261110101908.2e64e8e9@kernel.org/
> Cc: stable@vger.kernel.org
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
[Severity: Low]
The commit sha 1da177e4c3f4 ("Linux-2.6.12-rc2") in the Fixes: trailer cannot
be resolved in the repository.
> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index d6e9c7c59a892..1b556fa17c57c 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c
> @@ -1339,6 +1339,9 @@ static void neigh_update_process_arp_queue(struct neighbour *neigh)
> if (n2)
> n1 = n2;
> }
> + /* headerless output transmits on skb->dev, not n1->dev */
> + if (!n1->dev->header_ops)
> + skb->dev = n1->dev;
> READ_ONCE(n1->output)(n1, skb);
> if (n2)
> neigh_release(n2);
[Severity: Medium]
Can setting skb->dev = n1->dev misroute packets redirected by
nft_fwd_neigh_eval() or __bpf_redirect_neigh_v4() / __bpf_redirect_neigh_v6()
when the original dst points to a headerless device?
As noted in the commit message, those paths leave the original skb_dst(skb)
attached when queuing on an unresolved target neighbour, and neither producer
has been updated to drop the dst yet:
net/netfilter/nft_fwd_netdev.c:nft_fwd_neigh_eval() {
...
skb->dev = dev;
skb_clear_tstamp(skb);
nf_dev_xmit_recursion_inc();
neigh_xmit(neigh_table, dev, addr, skb);
...
}
When the target neighbour resolves, dst_neigh_lookup_skb(dst, skb) finds n2 on
the original headerless device, overwrites skb->dev with n1->dev, and
reinjects the packet through neigh_direct_output() -> dev_queue_xmit() onto
the original device instead of the redirected target. If the redirect ran in
n1->dev's egress hook, nft_fwd_neigh_eval() runs a second time and decrements
iph->ttl or ip6h->hop_limit again; if the redirect happened outside n1->dev's
egress hook, the redirect is lost and the packet transmits out n1->dev.
Similarly, tcf_mirred_to_dev() retains skb_dst() on egress redirect or mirror.
--
Sashiko AI review · https://sashiko.dev/#/patchset/QDISC-6HS9.v5.r0.20261116052927@mojatatu.com?part=2
next prev parent reply other threads:[~2026-11-17 10:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 10:36 [PATCH net v5 0/3] net/sched: sch_teql: keep the transmit path's skb geometry and device lifetime intact Jamal Hadi Salim
2026-11-16 10:36 ` [PATCH net v5 1/3] net/sched: sch_teql: unshare the header before writing and fix retry strip Jamal Hadi Salim
2026-11-16 10:36 ` [PATCH net v5 2/3] net: neighbour: reinject a parked skb through a headerless output device Jamal Hadi Salim
2026-11-17 10:36 ` sashiko-bot [this message]
2026-11-16 10:36 ` [PATCH net v5 3/3] net/sched: sch_teql: keep skb->dev consistent on the arp-queue path Jamal Hadi Salim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-218641@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jhs@mojatatu.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.