Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jhs@mojatatu.com
Cc: netdev@vger.kernel.org, victor@mojatatu.com, jiri@resnulli.us,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, stable@vger.kernel.org,
	sashiko-bot@kernel.org
Subject: Re: [PATCH net v6 3/3] net/sched: sch_teql: keep skb->dev consistent on the arp-queue path
Date: Mon, 23 Nov 2026 13:01:24 +0000	[thread overview]
Message-ID: <179543888407.3135.9702684913821781475@kernel.org> (raw)
In-Reply-To: <QDISC-6HS9.v6.r0.20261119070330-3@mojatatu.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 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).

- [High] The use-after-free class this patch claims to close is still
  reachable, and is now easier to trigger.
- [Medium] Wrong egress device when a parked skb whose dst points at a
  third device is reinjected.
- [Medium] The stable tags do not record that this patch depends on
  another.
- [Low] The commit message understates how the move changes ICMPv6 error
  generation.

--

net/sched: sch_teql: keep skb->dev consistent on the arp-queue path

This patch moves the skb->dev = slave assignment in teql_master_xmit()
ahead of teql_resolve(). An skb parked on the slave neighbour's arp_queue
then names the slave rather than the teql master, which avoids a
use-after-free when teql_exit() frees the master on module unload. It
depends on an earlier patch that changes neigh_update_process_arp_queue()
to reinject parked skbs through a headerless output device.

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/
Link: https://lore.kernel.org/netdev/179363700308.3131.11778179538290251434@kernel.org/
Link: https://lore.kernel.org/netdev/20261110101908.2e64e8e9@kernel.org/

> The error now names the slave, so it is also routed for the slave: IPv4
> takes the ICMP output interface from icmp_get_route_lookup_dev() and IPv6
> from skb->dev. A teql master enslaved to a VRF had its host-unreachable
> looked up in the VRF and now has it looked up in the main tables with
> oif 0.

[Severity: Low]
Does this cover everything that changes on the IPv6 side? On the
neigh_invalidate()->ndisc_error_report()->dst_link_failure()->
ip6_link_failure() path, icmp6_send() takes more than the l3mdev from
skb->dev:

net/ipv6/icmp.c:icmp6_send() {
    ...
	net = dev_net_rcu(skb->dev);
    ...
	if (ipv6_chk_addr(net, &hdr->daddr, skb->dev, 0) ||
	    ipv6_chk_acast_addr_src(net, skb->dev, &hdr->daddr))
		saddr = &hdr->daddr;
    ...
	if (__ipv6_addr_needs_scope_id(addr_type)) {
		iif = icmp6_iif(skb);
    ...
}

teql_qdisc_init() checks that master and slave share a netns only when the
slave is attached. teql_master_setup() does not set netns_immutable. If the
master is moved later, the error is now generated, rate-limited and routed
in the slave's namespace.

For a source that needs a scope id (link-local), iif is now the slave's
ifindex rather than 0, so "oif 0" doesn't hold there.

The saddr check through ipv6_chk_addr() and ipv6_chk_acast_addr_src() also
runs against the slave now.

Could the commit message describe these effects as well?

> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

[ ... ]

> Cc: stable@vger.kernel.org

[Severity: Medium]
The patch has a plain Cc: stable and a Fixes tag that points at the initial
git import. Stable tooling will therefore pick this one-line move for nearly
every stable tree, and it will apply cleanly.

The commit message says this patch is only correct on top of "net:
neighbour: reinject a parked skb through a headerless output device". That
prerequisite changes neigh_update_process_arp_queue(), which only exists
since 705ef89ac986. In older trees the loop is open coded in
__neigh_update(), so the prerequisite won't apply there.

If this patch is backported alone, the parked skb with skb->dev = slave is
reinjected through the master's neighbour. teql_master_setup() sets
ARPHRD_VOID and installs no header_ops, so the output is
neigh_direct_output(). dev_queue_xmit() then sends the skb straight out the
slave with no link header, because __teql_resolve() already pulled it to
the network header.

Would it make sense to record the dependency in the stable tag (for example
"Cc: stable@vger.kernel.org # <version>: <sha>: <subject>"), limit the
versions, or provide a backport of the prerequisite for the open-coded loop
in __neigh_update()?

> diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
> index 44730a5e89178..d1c66bd039d1d 100644
> --- a/net/sched/sch_teql.c
> +++ b/net/sched/sch_teql.c
> @@ -379,13 +379,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 when teql0 gets an skb whose dst->dev is another device X
that has header_ops? One way this happens is a tc mirred redirect or mirror
from X's clsact egress. tcf_mirred_to_dev() keeps the dst for egress to
egress, and only drops it for want_ingress && !at_ingress.

The skb is parked like this:

teql_master_xmit()
  skb->dev = slave;
  teql_resolve()
    __teql_resolve()                  /* dst->dev != dev branch */
      neigh_event_send(n, skb_res)    /* parks on the slave's neighbour */

When the slave's neighbour resolves:

neigh_update_process_arp_queue()
  n1 = neighbour looked up from the dst   /* X's neighbour */
  if (!n1->dev->header_ops)
      skb->dev = n1->dev;                 /* not taken, X has header_ops */
  n1->output(n1, skb)
    neigh_resolve_output() / neigh_connected_output()
      dev_hard_header(skb, X, ...)        /* X's MAC and lladdr */
      dev_queue_xmit(skb)                 /* sends on skb->dev == slave */

Does the frame then leave the slave carrying X's link header?

Before this patch skb->dev was still teql0 at that point. dev_queue_xmit()
went back through teql_master_xmit(), which pulled to the network header
and built the slave's own header.

This looks like the mirror-parking scenario that "net/sched: sch_teql:
unshare the header before writing and fix retry strip" uses as its
reproducer. Is that queued frame now sent with the wrong addresses at the
end of the series?

[Severity: High]
Can the same path still lead to a use-after-free, now of the slave instead
of the master?

Continuing from the reinjection above, X's neighbour may not be valid at
that moment. It could be NONE, INCOMPLETE or FAILED, for example after ip
neigh flush dev X, a carrier-down flush, or gc:

neigh_resolve_output()
  neigh_event_send(neigh, skb)    /* queued on X's arp_queue,
                                     skb->dev == slave */

skb->dev holds no device reference. If the slave is then deleted with ip
link del:

neigh_ifdown(slave)
  neigh_flush_dev()               /* walks only the slave's own neighbours */

The skb on X's arp_queue survives this, and the slave's net_device is
freed. When X's neighbour then fails:

neigh_invalidate()
  arp_error_report() / ndisc_error_report()
    dst_link_failure()
      __icmp_send() / icmp6_send()   /* reads skb->dev, the freed slave */

That gives the same KASAN signature as the one in the commit message. If
X's neighbour resolves instead, dev_queue_xmit() would run on the freed
slave.

Before this patch the skb on X's queue named teql0, which only module
unload can free.

The commit message says the parked skb "names the device whose neighbour
owns it". Does that still hold once the skb moves to a different
neighbour's queue? If not, the trigger seems to change from
CAP_SYS_MODULE plus rmmod to an ordinary link deletion.

>  		case 0:
>  			if (__netif_tx_trylock(slave_txq)) {
>  				unsigned int length = qdisc_pkt_len(skb);
>  				int rc = NETDEV_TX_BUSY;
>
> -				skb->dev = slave;
>  				if (!netif_xmit_frozen_or_stopped(slave_txq))
>  					rc = netdev_start_xmit(skb, slave, slave_txq, false);
>  				__netif_tx_unlock(slave_txq);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-6HS9.v6.r0.20261119070330%40mojatatu.com

      reply	other threads:[~2026-11-23 13:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 12:40 [PATCH net v6 0/3] net/sched: sch_teql: keep the transmit path's skb geometry and device lifetime intact Jamal Hadi Salim
2026-11-19 12:40 ` [PATCH net v6 1/3] net/sched: sch_teql: unshare the header before writing and fix retry strip Jamal Hadi Salim
2026-11-23 13:01   ` netdev-bot+sashiko
2026-11-19 12:40 ` [PATCH net v6 2/3] net: neighbour: reinject a parked skb through a headerless output device Jamal Hadi Salim
2026-11-23 13:01   ` netdev-bot+sashiko
2026-11-19 12:40 ` [PATCH net v6 3/3] net/sched: sch_teql: keep skb->dev consistent on the arp-queue path Jamal Hadi Salim
2026-11-23 13:01   ` netdev-bot+sashiko [this message]

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=179543888407.3135.9702684913821781475@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sashiko-bot@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=victor@mojatatu.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox