Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 2 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The new gate in neigh_update_process_arp_queue()
(net/core/neighbour.c:1343-1344), `if (!n1->dev->header_ops) skb->dev…
- [Medium] teql_master_xmit() now sets skb->dev = slave before
teql_resolve() (sch_teql.c:371).
- [Low] The commit message's reproducer cannot show the use-after-free
the patch says it fixes.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
teql_qdisc_init() (net/sched/sch_teql.c:194-253) never checks that the…
--
net/sched: sch_teql: keep skb->dev consistent on the arp-queue path
This patch moves skb->dev = slave ahead of teql_resolve(). An skb parked
on the slave's arp_queue then names the slave instead of the teql master.
It also restores skb->dev = n1->dev in neigh_update_process_arp_queue()
when the top-level neighbour's device has no header_ops, so the skb goes
back through teql_master_xmit().
Link: https://lore.kernel.org/netdev/20260824115928.4099988-1-victor@mojatatu.com/
Link: https://lore.kernel.org/netdev/20261026160747.283702-1-horms@kernel.org/
Link: https://lore.kernel.org/netdev/20261031165925.780930-1-horms@kernel.org/
Conditions to recreate the bug:
CONFIG_NET_SCH_TEQL=y, CONFIG_VETH=y, run as root. 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:
[ ... ]
On the unfixed tree the skb is parked on v0's arp_queue while skb->dev
still names teql0, so the reinjection can reach a master that teql_exit()
has freed.
[Severity: Low]
Can this recipe reach the use-after-free it describes?
With CONFIG_NET_SCH_TEQL=y, teql_exit() is __exit and never runs, so no
master is ever freed:
net/sched/sch_teql.c:teql_exit() {
...
unregister_qdisc(&master->qops);
unregister_netdev(master->dev);
free_netdev(master->dev);
...
}
teql_master_setup() installs no rtnl_link_ops, so "ip link del teql0"
can't free the master either.
Building sch_teql as a module doesn't change this. teql_master_setup()
sets ops->owner = THIS_MODULE, and qdisc_lookup_ops() takes a module
reference through bpf_try_module_get() for each slave qdisc. rmmod
therefore fails while the slave qdisc on v0 exists.
To reach a freed master you seem to need sch_teql as a module, then
"tc qdisc del dev v0 root", then "rmmod sch_teql". All of this has to
happen while the skb is still parked on v0's arp_queue. None of these
steps are in the recipe. Could the recipe be updated to match?
Also, the message only names the reinjection path. Commit dc4b95b8fee9
showed this KASAN-confirmed path for a stale skb->dev:
neigh_invalidate()->arp_error_report()->ipv4_link_failure()->__icmp_send()
Here __icmp_send() reads skb_in->dev. This patch covers that path too,
because the parked skb now names the slave. Would it be worth saying so
in the message?
quoted hunk
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index d6e9c7c59a892..541cf699abae4 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 outputs (teql, shaper) transmit on skb->dev */
+ if (!n1->dev->header_ops)
+ skb->dev = n1->dev;
READ_ONCE(n1->output)(n1, skb);
[Severity: Medium]
Is this check narrow enough to match only teql?
n1 comes from dst_neigh_lookup_skb() on the skb's retained dst. It does
not come from neigh, the neighbour the skb was parked on. Nothing checks
that neigh->dev is a teql slave of n1->dev, so any headerless route
device matches.
Two producers park the skb on another device Y's neighbour while keeping
the original route's dst:
- nft "fwd ... neigh", via nft_fwd_neigh_eval(). nft_fwd_validate()
allows it at NF_NETDEV_EGRESS.
- bpf_redirect_neigh() with an explicit nexthop.
__bpf_redirect_neigh_v4/v6 only replace the dst when nh == NULL.
Suppose such a forward runs at the egress hook of a headerless device X
and the neighbour on Y is unresolved:
__neigh_event_send()
skb_dst_force(skb) /* dst->dev is still X */
queue on Y's arp_queue
neigh_update_process_arp_queue()
n1 = dst_neigh_lookup_skb(dst, skb) /* X's neighbour */
skb->dev = n1->dev /* X */
neigh_direct_output()->dev_queue_xmit(X)
nf_skip_egress was reset after sch_handle_egress(), so nf_hook_egress()
runs X's egress chain a second time.
The forward then runs twice. nft_fwd_neigh_eval() decrements TTL again,
so a TTL=2 packet that should leave Y with TTL 1 is dropped here on the
second pass:
if (iph->ttl <= 1) {
verdict = NF_DROP;
goto out;
}22 more lines
quoted hunk
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index ed8faa848f184..4eac1f9c8ddf6 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -368,13 +368,13 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)
continue;
}
+ skb->dev = slave;
switch (teql_resolve(skb, skb_res, slave, slave_txq, &hlen)) {
[Severity: Medium]
What happens to an skb parked here if the neighbour then fails?
In case 1 of teql_resolve(), teql_master_xmit() returns before the
skb->dev = dev restore at the bottom of the loop. The skb therefore sits
on the slave's arp_queue with skb->dev = slave.
Only neigh_update_process_arp_queue() was changed to put the master back.
The other consumer of the queue passes the skb on unchanged:
net/core/neighbour.c:neigh_invalidate() {
...
while (neigh->nud_state == NUD_FAILED &&
(skb = __skb_dequeue(&neigh->arp_queue)) != NULL) {
write_unlock(&neigh->lock);
neigh->ops->error_report(neigh, skb);
...
}
For IPv6 the call chain is:
ndisc_error_report()->dst_link_failure()->ip6_link_failure()->
icmpv6_send()->icmp6_send()
icmp6_send() takes its context from skb->dev:
net = dev_net_rcu(skb->dev);
...
iif = l3mdev_master_ifindex(skb->dev);
It also uses ipv6_chk_addr(net, &hdr->daddr, skb->dev, 0), and
icmp6_iif(skb) for link-local sources. That iif becomes flowi6_oif for
the route lookup of the error.
These values used to come from the teql master. Now they come from the
slave, which changes the result in these setups:
- teql0 in a VRF with the slave outside it: the ICMPv6 Destination
Unreachable is routed in the main table instead of the VRF table.50 more lines