Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH net v5 0/3] net/sched: sch_teql: keep the transmit path's skb geometry and device lifetime intact
@ 2026-11-16 10:36 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
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jamal Hadi Salim @ 2026-11-16 10:36 UTC (permalink / raw)
  To: netdev
  Cc: Jamal Hadi Salim, David Ahern, Ido Schimmel, Victor Nogueira,
	Jiri Pirko, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Kuniyuki Iwashima, Simon Horman, bpf, stable,
	sashiko-bot

Three pre-existing defects on the teql transmit path, all around
teql_master_xmit() -> teql_resolve(), plus the core helper they depend on
all derived from sashiko reports.

Patch 1 makes the headroom private before the neighbour can write or queue
the skb, and pulls back only the header that slave added, so a
header-cloned skb is not corrupted and a userspace-supplied link header
survives a retry.

Patch 2 restores skb->dev at the arp-queue reinjection point when the
neighbour's device builds no link header. It is the neighbour half of the
version 3 patch 2, split out on review so it gets its own commit
log and its own Cc set; requested by Jakub.

Patch 3 moves skb->dev = slave ahead of teql_resolve() so a skb parked on a
slave's neighbour arp_queue names the device whose neighbour took it, and
so cannot outlive the master it came from.  With patch 2 in place it is
reinjected through the master and leaves with a link header.  Its commit
log carries the KASAN report the unfixed kernel prints when that queue is
drained.

Patch 3 is a follow-up to commit dc4b95b8fee9 ("net/sched: sch_teql:
restore skb->dev on the slave failure path") by Victor. Patch 1 is the
same commit's sibling on the successful-transmit path.

To prempt the sashikos:
- The pre-existing teql issues reported alongside this series are fixed
separately. For "the lower-qdisc drop use-after-free" see:
https://lore.kernel.org/netdev/QDISC-Y0BY.v2.r0.20261024060625-2@mojatatu.com/

- For the pre-existing consumer nft/bpf complaint see:
https://lore.kernel.org/netdev/CORE-9NOG.v1.r0.20261111073528@mojatatu.com/
Note: nft/bpf combination _has never worked_: it is a producer-side
mismatch on two separate entry points, not a regression of anything here -
hence the net-next target.

Hope the sashikos read these and dont complain again about those issues.

Note also: part of the testing of patch 2 runs for packets that reach
neigh_xmit() from nft's `fwd ... neigh` statement, or from
bpf_redirect_neigh() with explicit nexthop parameters. Both keep the
route's dst attached while replacing skb->dev, so the neighbour that
queues the packet is not the one the dst names.

Changes v4 -> v5:
- patch 1 closes the finding Sashiko (nipa) raised on the v4 posting.  The
  head is unshared before neigh_event_send(), so a skb parked on the
  slave's neighbour arp_queue is already private when that queue is
  drained and the neighbour writes the link header into it.  The retry
  strip fix is unchanged.  Considered comments from Sashiko (nipa).
- patches 2 and 3 are unchanged; this resend is for patch 1.
- patch 2 adds Kuniyuki Iwashima in its Cc set (nipa CI).

Changes v3 -> v4:
- patch 1, no code changes. Reviewed-by from Simon Horman stays, and a
  Link to the review of the v3 posting is added.
- patch 2 is new: the net/core/neighbour.c hunk of the v3 patch 2 is split
  out into its own fix, with the neighbour maintainers Cc'd.  Asked for on
  the v3 posting by Jakub.
- patch 3 is the v3 patch 2 with that hunk removed; the sch_teql change is
  unchanged in approach. Reviewed-by from Simon Horman stays.

Changes v2 -> v3:
- patch 1, no code changes.
- patch 2 corrects the conditions to recreate the bug: reaching a freed
  master needs sch_teql built as a module, the slave qdisc removed and the
  module unloaded while the skb still waits.  The message now says which
  part of it reproduces without the unload, and names the neighbour failure
  path that drains the same parked skb.  Considered comments from
  Sashiko (nipa).

Changes v1 -> v2:
- patch 1, no code changes.
- patch 2 limits the reinjection restore to a top-level neighbour whose
  device has no header_ops, the shaper/eql/sch_teql class.  Commit message
  also describes how a master is freed.  Considered comments from
  Sashiko (nipa) and Sashiko (gemini).

Jamal Hadi Salim (3):
  net/sched: sch_teql: unshare the header before writing and fix retry
    strip
  net: neighbour: reinject a parked skb through a headerless output
    device
  net/sched: sch_teql: keep skb->dev consistent on the arp-queue path

 net/core/neighbour.c |  3 +++
 net/sched/sch_teql.c | 27 +++++++++++++++++++++------
 2 files changed, 24 insertions(+), 6 deletions(-)

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net v5 1/3] net/sched: sch_teql: unshare the header before writing and fix retry strip
  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 ` Jamal Hadi Salim
  2026-11-19 10:38   ` netdev-bot+sashiko
  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-16 10:36 ` [PATCH net v5 3/3] net/sched: sch_teql: keep skb->dev consistent on the arp-queue path Jamal Hadi Salim
  2 siblings, 1 reply; 8+ messages in thread
From: Jamal Hadi Salim @ 2026-11-16 10:36 UTC (permalink / raw)
  To: netdev
  Cc: Jamal Hadi Salim, Victor Nogueira, Jiri Pirko, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, stable,
	sashiko-bot

This is a followup of commit dc4b95b8fee9 ("net/sched: sch_teql: restore
skb->dev on the slave failure path") as reported by Sashiko.

The issue:
teql_master_xmit() writes the slave's link header into the skb in
teql_resolve() and on retry pulls it back with __skb_pull().  Two bugs:

1. When the skb's header is cloned (e.g. a tc-mirred action on a
   physical device's clsact egress redirects to the teql master), the
   write corrupts the other clone.  Call skb_cow_head() first.

2. The pull always removes skb_network_offset() bytes.  For an
   AF_PACKET/SOCK_RAW frame with no dst entry, teql_resolve() adds no
   header, so the retry strips the user-supplied one.  Pull back only
   the length this slave added.

The Fix:
Unshare the header before the neighbour is asked to send the skb, so the
skb is private whether the neighbour writes the link header at once or
parks it on its arp_queue and writes it when the entry resolves.  Track
the added length per iteration; an AF_PACKET frame retries with its
header intact.

Conditions to recreate the bug:
CONFIG_NET_SCH_TEQL=y and CONFIG_VETH=y, run as root. A teql master with
two veth slaves, the first slave returning NETDEV_TX_BUSY without
consuming the skb so that teql retries the frame on the second one:

  ip link add vethBAD type veth peer name vethBADp
  ip link add vethGOOD type veth peer name vethGOODp
  ip link set vethBAD up;  ip link set vethBADp up
  ip link set vethGOOD up; ip link set vethGOODp up
  tc qdisc add dev vethBAD root teql0
  tc qdisc add dev vethGOOD root teql0
  ip link set teql0 up

Send a SOCK_RAW frame that carries its own link header on teql0 and
capture it on the second slave's peer. A veth transmit does not return
NETDEV_TX_BUSY on its own; to hold the skb pending this reproduction used
a test-only IFF_DEBUG accelerator in veth_xmit(), which is not part of
this patch and was applied to both the unfixed and the fixed build.

On the unfixed tree the captured frame arrives with its header stripped
(176 of the 208 bytes sent, starting at the payload) because the retry
pulls skb_network_offset() bytes while this slave added none. With the
patch the frame arrives intact.

The shared headroom case needs a second reference to the skb to survive
the transmit. A PF_PACKET tap on the master whose socket is never
drained keeps one alive; a kprobe on eth_header then reports cloned=1
without the patch and cloned=0 with it. The parked path needs the
unshare before the queue: a tc-mirred mirror on a physical device's
clsact egress parks the clone on the teql slave's unresolved neighbour,
so hold the original frame in a netem delay on that device and then
resolve the slave's neighbour through a changed lladdr. Without the
unshare the arp-queue drain writes the new link header over the original
frame's first bytes, and a listener on the peer sees a frame addressed
to the new lladdr instead of to itself; with the patch the queued frame
keeps its own destination address.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Sashiko (gemini) <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260824115928.4099988-1-victor@mojatatu.com
Reported-by: Sashiko (nipa) <sashiko-bot@kernel.org>
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-6HS9.v4.r0.20261111094338-1%40mojatatu.com
Link: https://lore.kernel.org/netdev/20260824115928.4099988-1-victor@mojatatu.com/
Link: https://lore.kernel.org/netdev/20261110101908.2e64e8e9@kernel.org/
Cc: stable@vger.kernel.org
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
v4 -> v5:
- unshare the skb header before the neighbour is asked to send it, not
  only on the path where the neighbour writes the link header at once.
  A skb parked on the slave's arp_queue is drained through
  neigh_update_process_arp_queue(), which writes the header itself, so
  the unshare has to happen before neigh_event_send().
- the shared-headroom paragraph of "Conditions to recreate the bug" now
  describes that parked path.

 net/sched/sch_teql.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index dc21cd9704a2..626dc001ec23 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -262,7 +262,7 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,
 static int
 __teql_resolve(struct sk_buff *skb, struct sk_buff *skb_res,
 	       struct net_device *dev, struct netdev_queue *txq,
-	       struct dst_entry *dst)
+	       struct dst_entry *dst, int *hlen)
 {
 	struct neighbour *n;
 	int err = 0;
@@ -292,16 +292,26 @@ __teql_resolve(struct sk_buff *skb, struct sk_buff *skb_res,
 		n = mn;
 	}
 
+	/* Unshare the head before the neighbour can write or queue it. */
+	if (skb_cow_head(skb, LL_RESERVED_SPACE(dev)) < 0) {
+		err = -ENOMEM;
+		goto out;
+	}
+
 	if (neigh_event_send(n, skb_res) == 0) {
+		int off = skb_network_offset(skb);
 		char haddr[MAX_ADDR_LEN];
 
 		neigh_ha_snapshot(haddr, n, dev);
 		if (dev_hard_header(skb, dev, ntohs(skb_protocol(skb, false)),
 				    haddr, NULL, skb->len) < 0)
 			err = -EINVAL;
+		/* The bytes prepended above skb->data, pulled back on retry. */
+		*hlen = skb_network_offset(skb) - off;
 	} else {
 		err = (skb_res == NULL) ? -EAGAIN : 1;
 	}
+out:
 	neigh_release(n);
 	return err;
 }
@@ -309,11 +319,13 @@ __teql_resolve(struct sk_buff *skb, struct sk_buff *skb_res,
 static inline int teql_resolve(struct sk_buff *skb,
 			       struct sk_buff *skb_res,
 			       struct net_device *dev,
-			       struct netdev_queue *txq)
+			       struct netdev_queue *txq,
+			       int *hlen)
 {
 	struct dst_entry *dst = skb_dst(skb);
 	int res;
 
+	*hlen = 0;
 	if (rcu_access_pointer(txq->qdisc) == &noop_qdisc)
 		return -ENODEV;
 
@@ -321,7 +333,7 @@ static inline int teql_resolve(struct sk_buff *skb,
 		return 0;
 
 	rcu_read_lock();
-	res = __teql_resolve(skb, skb_res, dev, txq, dst);
+	res = __teql_resolve(skb, skb_res, dev, txq, dst, hlen);
 	rcu_read_unlock();
 
 	return res;
@@ -335,6 +347,7 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)
 	struct Qdisc *start, *q;
 	unsigned long flags;
 	int nores;
+	int hlen;
 	int busy;
 
 restart:
@@ -361,7 +374,7 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)
 			continue;
 		}
 
-		switch (teql_resolve(skb, skb_res, slave, slave_txq)) {
+		switch (teql_resolve(skb, skb_res, slave, slave_txq, &hlen)) {
 		case 0:
 			if (__netif_tx_trylock(slave_txq)) {
 				unsigned int length = qdisc_pkt_len(skb);
@@ -408,8 +421,10 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)
 			nores = 1;
 			break;
 		}
+		/* Pull back only the header this slave added. */
+		if (hlen > 0)
+			__skb_pull(skb, hlen);
 		skb->dev = dev;
-		__skb_pull(skb, skb_network_offset(skb));
 	} while ((q = rcu_dereference(NEXT_SLAVE(q))) != start);
 
 	if (nores && skb_res == NULL) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net v5 2/3] net: neighbour: reinject a parked skb through a headerless output device
  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 ` Jamal Hadi Salim
  2026-11-19 10:38   ` netdev-bot+sashiko
  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
  2 siblings, 1 reply; 8+ messages in thread
From: Jamal Hadi Salim @ 2026-11-16 10:36 UTC (permalink / raw)
  To: netdev
  Cc: Jamal Hadi Salim, David Ahern, Ido Schimmel, Victor Nogueira,
	Jiri Pirko, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Kuniyuki Iwashima, Simon Horman, bpf, stable

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>
---
 net/core/neighbour.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index d6e9c7c59a89..1b556fa17c57 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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net v5 3/3] net/sched: sch_teql: keep skb->dev consistent on the arp-queue path
  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-16 10:36 ` Jamal Hadi Salim
  2026-11-19 10:38   ` netdev-bot+sashiko
  2 siblings, 1 reply; 8+ messages in thread
From: Jamal Hadi Salim @ 2026-11-16 10:36 UTC (permalink / raw)
  To: netdev
  Cc: Jamal Hadi Salim, Victor Nogueira, Jiri Pirko, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, stable,
	sashiko-bot

This is a follow-up to commit dc4b95b8fee9 ("net/sched: sch_teql: restore
skb->dev on the slave failure path") by Victor Nogueira, which covered the
slave side of the same mismatch.

The issue:
teql_master_xmit() sets skb->dev = slave only right before the slave's
ndo_start_xmit(). If the slave's neighbour is unresolved, teql_resolve()
parks the skb on the slave's arp_queue with skb->dev still naming the teql
master. teql_exit() frees the masters on module unload and a slave can
outlive them, so a queued skb can be reinjected through freed memory.

The Fix:
Set skb->dev = slave before teql_resolve() so the parked skb names the
device whose neighbour owns it.

The parked skb has a second consumer: when the neighbour fails instead of
resolving, neigh_invalidate() hands it to error_report() and
dst_link_failure(), which read skb->dev to report the failure, so it names
the slave on that path too.

A parked skb is reinjected by neigh_update_process_arp_queue(), and a
device that transmits straight on skb->dev has to be handed its skb back
there. That is a change to net/core/neighbour.c, posted as its own fix,
and it has to be applied before this one: without it the parked packet
leaves the slave directly, with no link header, because teql_master_xmit()
has already pulled it.

Some context:
Only a module unload frees a master. teql_master_setup() installs no
rtnl_link_ops and default_device_exit_net() moves the device to init_net
when its namespace exits, so the window is a parked skb plus CAP_SYS_MODULE
on an unloaded sch_teql.

Conditions to recreate the bug:
CONFIG_NET_SCH_TEQL=m and 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:

  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 &
  sleep 1

The skb waits on v0's arp_queue while the solicitation is in flight.
Remove the qdisc, which drops the module reference it holds, and unload
the module while the skb still waits:

  tc qdisc del dev v0 root
  rmmod sch_teql

teql_exit() frees teql0 there. When the solicitation then fails,
neigh_invalidate() drains the queue through arp_error_report() and
ipv4_link_failure(), whose __icmp_send() reads skb_in->dev; that is the
freed master before this patch and v0 after it. A resolved neighbour
drains the same queue through neigh_update_process_arp_queue().

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.

The park and the headerless delivery reproduce without the unload.
Freeing the master while the skb waits needs sch_teql built as a module,
as above.

An unfixed kernel reports this when the timer drains that queue:

  ==================================================================
  BUG: KASAN: slab-use-after-free in __icmp_send+0x3f9/0x1680
  Read of size 4 at addr ffff8880039bc0b0 by task swapper/3/0

  CPU: 3 UID: 0 PID: 0 Comm: swapper/3
  Call Trace:
   <IRQ>
   ...
   __icmp_send+0x3f9/0x1680
   ipv4_link_failure+0x3a0/0x5b0
   arp_error_report+0x5b/0xc0
   neigh_invalidate+0x125/0x240
   neigh_timer_handler+0x47d/0x750
   call_timer_fn+0x138/0x410
   ...
  Allocated by task 307:
   alloc_netdev_mqs+0x81/0x930
   ...
  Freed by task 335:
   netdev_release+0x45/0x60
   device_release+0x7d/0x120
   kobject_put+0xf3/0x2e0
   put_device+0x13/0x30
   free_netdev+0x3b3/0x4a0
   ...

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Sashiko (nipa) <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260824115928.4099988-1-victor@mojatatu.com
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/
Cc: stable@vger.kernel.org
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 net/sched/sch_teql.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index 626dc001ec23..e60d8f3b127d 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -374,13 +374,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)) {
 		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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net v5 1/3] net/sched: sch_teql: unshare the header before writing and fix retry strip
  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-19 10:38   ` netdev-bot+sashiko
  2026-11-19 11:46     ` Jamal Hadi Salim
  0 siblings, 1 reply; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19 10:38 UTC (permalink / raw)
  To: jhs
  Cc: netdev, victor, jiri, davem, edumazet, kuba, pabeni, horms,
	stable, sashiko-bot

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

Critical: 0 · High: 0 · Medium: 1 · Low: 0

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] This patch changes how teql_master_xmit()
  (net/sched/sch_teql.c) retries when an skb has a dst attached and…

--

net/sched: sch_teql: unshare the header before writing and fix retry strip

This patch calls skb_cow_head() in __teql_resolve() before the slave
neighbour can write or queue the skb, so a cloned header is not
corrupted. It also changes the retry path in teql_master_xmit(). The
retry now pulls back only the bytes the current slave pushed, instead of
pulling to the network header, so AF_PACKET frames without a dst keep
their own link header.

Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-6HS9.v4.r0.20261111094338-1%40mojatatu.com
Link: https://lore.kernel.org/netdev/20260824115928.4099988-1-victor@mojatatu.com/
Link: https://lore.kernel.org/netdev/20261110101908.2e64e8e9@kernel.org/

> diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
> index dc21cd9704a25..626dc001ec231 100644
> --- a/net/sched/sch_teql.c
> +++ b/net/sched/sch_teql.c

[ ... ]

>  	if (neigh_event_send(n, skb_res) == 0) {
> +		int off = skb_network_offset(skb);
>  		char haddr[MAX_ADDR_LEN];
>  
>  		neigh_ha_snapshot(haddr, n, dev);
>  		if (dev_hard_header(skb, dev, ntohs(skb_protocol(skb, false)),
>  				    haddr, NULL, skb->len) < 0)
>  			err = -EINVAL;
> +		/* The bytes prepended above skb->data, pulled back on retry. */
> +		*hlen = skb_network_offset(skb) - off;
>  	} else {
>  		err = (skb_res == NULL) ? -EAGAIN : 1;
>  	}

[ ... ]

> @@ -408,8 +421,10 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)
>  			nores = 1;
>  			break;
>  		}
> +		/* Pull back only the header this slave added. */
> +		if (hlen > 0)
> +			__skb_pull(skb, hlen);
>  		skb->dev = dev;
> -		__skb_pull(skb, skb_network_offset(skb));
>  	} while ((q = rcu_dereference(NEXT_SLAVE(q))) != start);

[Severity: Medium]
What happens on retry when the skb has a dst and already carries
link-layer bytes in front of its network header?

The old retry reset skb->data to the network header. That matches what
neigh_resolve_output() and neigh_connected_output() do before building
a header:

net/core/neighbour.c:neigh_resolve_output() {
    ...
		do {
			__skb_pull(skb, skb_network_offset(skb));
			seq = read_seqbegin(&neigh->ha_lock);
			err = dev_hard_header(skb, dev, ntohs(skb->protocol),
					      neigh->ha, NULL, skb->len);
    ...
}

__teql_resolve() pushes the slave header at skb->data without pulling
to the network header first, and hlen only counts that push. So with
the new retry, any L2 bytes already present when teql_master_xmit() was
entered stay in place across every retry.

One path that still delivers such an skb, even with the rest of the
series applied, is nft fwd ... neigh on a netdev egress chain.
nft_fwd_validate() allows NF_NETDEV_EGRESS, and nft_fwd_neigh_eval()
neither pulls to the network header nor drops the dst:

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);
    ...
}

teql0 has no header_ops, so arp_constructor() installs
neigh_direct_output() for it:

nft_fwd_neigh_eval()
  neigh_xmit()
    neigh_direct_output()
      dev_queue_xmit(teql0)
        teql_master_xmit()
          __teql_resolve()

The skb arrives with eth0's header in front of the IP header (network
offset 14) and eth0's route dst still attached. Because dst->dev !=
slave, __teql_resolve() looks up the slave's neighbour. From there:

If the slave neighbour is resolved, dev_hard_header() pushes 14 bytes
and hlen = 14. If the trylock then fails or the slave returns
NETDEV_TX_BUSY, the retry pulls only 14 bytes. The next slave sends
slave header + eth0 header + IP, while the old code pulled 28 bytes
and sent a single header.

If the slave neighbour is unresolved (-EAGAIN, nores), hlen = 0 and
nothing is pulled. The next slave in the same pass gets the double
header, while the old code pulled the stale 14 bytes.

At this commit alone there is a second trigger: an arp_queue skb
drained back into teql0 after neigh_resolve_output() wrote an eth0
header. Here skb->dev = slave is only set inside case 0, so the parked
skb still has skb->dev pointing at teql0.

That second trigger is closed later in the series. "net/sched: sch_teql:
keep skb->dev consistent on the arp-queue path" sets skb->dev = slave
before teql_resolve(). "net: neighbour: reinject a parked skb through a
headerless output device" only reverts skb->dev to a headerless
n1->dev, whose output is neigh_direct_output(), so no header is written
in that case. The nft fwd path above is not affected by either change.

The AF_PACKET case in the commit message only seems to need the
dst == NULL early return in teql_resolve(), where hlen is always 0.
Would it work to keep pulling to the network header for skbs with a
dst? Another option would be to pull to the network header in
__teql_resolve() before dev_hard_header(), as neigh_resolve_output()
does.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net v5 2/3] net: neighbour: reinject a parked skb through a headerless output device
  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-19 10:38   ` netdev-bot+sashiko
  0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19 10:38 UTC (permalink / raw)
  To: jhs
  Cc: netdev, victor, jiri, davem, edumazet, kuba, pabeni, horms,
	stable, sashiko-bot

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

Critical: 0 · High: 0 · Medium: 1 (1) · 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] New regression in neigh_update_process_arp_queue()
  (net/core/neighbour.c:1343-1345).
- [Low] The commit message describes sch_teql as parking the skb "naming
  the slave", with skb->dev differing from n1->dev.

Pre-existing issues:
- [Medium] neigh_update_process_arp_queue() re-homes skb->dev only when
  n1->dev has no header_ops.

--

net: neighbour: reinject a parked skb through a headerless output device

This patch changes neigh_update_process_arp_queue() so that skb->dev is
set to n1->dev before n1->output is called, when n1->dev has no
header_ops. With that, neigh_direct_output() transmits on the device the
neighbour belongs to, not on whatever device the producer left in
skb->dev. The motivating producer is sch_teql, which parks skbs on the
slave's neighbour.

Link: https://lore.kernel.org/netdev/20261110101908.2e64e8e9@kernel.org/

> 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.

[Severity: Low]
Is this accurate for the tree this patch applies to?

At this commit, teql_master_xmit() sets skb->dev = slave only inside
case 0, right before netdev_start_xmit(). It then restores skb->dev = dev
at the end of each iteration. So the skb that __teql_resolve() parks via
neigh_event_send() still names the master, and n1->dev == skb->dev.

That makes the new assignment a no-op for teql at this commit, and the
"Conditions to recreate the bug" recipe does not reproduce on this commit
alone.

The last patch in the series, "net/sched: sch_teql: keep skb->dev
consistent on the arp-queue path", moves skb->dev = slave ahead of
teql_resolve(). Its message says this neighbour change has to be applied
first, so the ordering is fine.

This patch carries Fixes: and Cc: stable. Could the message name the
sch_teql patch it depends on, and say that the behaviour it describes
only exists once that patch is applied? The phrase "reached once sch_teql
parks the skb naming the slave" hints at this, but it is easy to miss.

> 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;

[Severity: Medium]
Can this gate send nft fwd ... neigh and bpf_redirect_neigh() skbs back
through the original device's egress path?

nft_fwd_neigh_eval() in net/netfilter/nft_fwd_netdev.c is allowed on
NF_NETDEV_EGRESS. It decrements the TTL or hop_limit and then does:

    skb->dev = dev;
    skb_clear_tstamp(skb);

    nf_dev_xmit_recursion_inc();
    neigh_xmit(neigh_table, dev, addr, skb);

It does not drop the dst of the original route first.

bpf_out_neigh_v4() and bpf_out_neigh_v6() in net/core/filter.c do the
same when explicit nexthop parameters are passed. The dst is only
replaced in the !nh branch of __bpf_redirect_neigh_v4/v6().

If the neighbour of the target device B is unresolved, the skb is parked
on B's arp_queue with the dst of the original device A still attached.
When B resolves:

neigh_update_process_arp_queue()
    n2 = dst_neigh_lookup_skb(dst, skb);   /* A's neighbour */
    if (!n1->dev->header_ops)              /* A is ppp, p2p GRE, teql */
        skb->dev = n1->dev;                /* skb->dev goes from B to A */
    READ_ONCE(n1->output)(n1, skb);        /* neigh_direct_output() */
        dev_queue_xmit(skb);               /* A's qdisc, nf/tc egress */

The skb then goes through A's qdisc, netfilter egress and tc egress a
second time:

- nft fwd neigh decrements the TTL again, so packets that arrive with
  ttl == 2 are now dropped.

- Counters, limits and quotas are charged twice.

- Non-idempotent rules (mark-guarded, an exhausted limit or quota,
  numgen) can let the packet leave on A, the device the redirect was
  meant to steer around.

Before this patch these skbs left B without a link header, which was
also broken. Running A's egress hooks a second time is new, though.

The commit message acknowledges this:

    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.

That change does not appear to be part of this series. The last patch,
"net/sched: sch_teql: keep skb->dev consistent on the arp-queue path",
only touches sch_teql.c.

Since this patch is tagged for stable, could the dst drop in
nft_fwd_neigh_eval() and bpf_out_neigh_v4/v6() go into the same series,
ordered ahead of this change?

>  		READ_ONCE(n1->output)(n1, skb);

[Severity: Medium]
This isn't a bug introduced by this patch, but the same mismatch between
skb->dev and n1->dev remains when n1->dev does have header_ops.

neigh_resolve_output() and neigh_connected_output() build the header
from neigh->dev and then transmit on skb->dev:

    err = dev_hard_header(skb, dev, ntohs(skb->protocol),
                          neigh->ha, NULL, skb->len);
    ...
    rc = dev_queue_xmit(skb);

Take an nft fwd neigh redirect, or bpf_redirect_neigh() with nh, from
Ethernet A to Ethernet B. Would the frames queued while B resolves leave
B carrying A's source and next-hop MACs?

Re-homing skb->dev unconditionally here would be wrong for those
producers. This case would probably also be fixed by the producer-side
dst drop that the commit message defers.

>  		if (n2)
>  			neigh_release(n2);

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net v5 3/3] net/sched: sch_teql: keep skb->dev consistent on the arp-queue path
  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
@ 2026-11-19 10:38   ` netdev-bot+sashiko
  0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19 10:38 UTC (permalink / raw)
  To: jhs
  Cc: netdev, victor, jiri, davem, edumazet, kuba, pabeni, horms,
	stable, sashiko-bot

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

Critical: 0 · High: 0 · Medium: 2 · Low: 0

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 patch carries `Cc: stable@vger.kernel.org` and only works
  if a net/core/neighbour.c fix is applied first, but the commit message…
- [Medium] The ICMP error for a failed neighbour resolution is now routed
  in the teql slave's L3 context instead of the master's.

--

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() so
that it happens before teql_resolve(). An skb parked on the slave's
arp_queue then names the slave instead of the teql master. This avoids a
use-after-free when sch_teql is unloaded and the master is freed while the
skb is still queued.

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/

> A parked skb is reinjected by neigh_update_process_arp_queue(), and a
> device that transmits straight on skb->dev has to be handed its skb back
> there. That is a change to net/core/neighbour.c, posted as its own fix,
> and it has to be applied before this one: without it the parked packet
> leaves the slave directly, with no link header, because teql_master_xmit()
> has already pulled it.

[ ... ]

> Cc: stable@vger.kernel.org

[Severity: Medium]
This patch carries Cc: stable, so could the prerequisite be named
explicitly? The text only says the neighbour.c change is "posted as its
own fix". It gives no commit id, subject or Link, and the stable tag has no
"# depends on" note.

The prerequisite looks like "net: neighbour: reinject a parked skb through
a headerless output device". It adds this to
neigh_update_process_arp_queue():

	/* headerless output transmits on skb->dev, not n1->dev */
	if (!n1->dev->header_ops)
		skb->dev = n1->dev;
	READ_ONCE(n1->output)(n1, skb);

neigh_update_process_arp_queue() was only split out of __neigh_update() by
commit 705ef89ac98648 ("net: core: neighbour: Extract ARP queue processing
to a helper function"). So the neighbour fix will not apply cleanly to
older stable trees.

This sch_teql hunk is a one-line move. Given the earlier sch_teql patch
that adds the &hlen argument, it would apply to those trees on its own.

If this patch reaches a stable tree without the neighbour fix, would an skb
parked on the slave's arp_queue go out with no link header?

When the neighbour resolves, neigh_update_process_arp_queue() looks up n1
again from the dst and gets the teql master's neighbour. The master has no
header_ops, so n1->output is neigh_direct_output(). That transmits on
skb->dev, which is now the slave:

neigh_update_process_arp_queue()
  n1->output() == neigh_direct_output()
    dev_queue_xmit(skb)   /* skb->dev == slave, header already pulled */

Would something like "Cc: stable@vger.kernel.org # depends on <commit>"
help keep the two patches together?

> diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
> index 626dc001ec231..e60d8f3b127de 100644
> --- a/net/sched/sch_teql.c
> +++ b/net/sched/sch_teql.c
> @@ -374,13 +374,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]
skb->dev is now set to the slave before teql_resolve(). So when
__teql_resolve()->neigh_event_send() parks the skb, skb->dev is the slave
while skb_dst(skb)->dev is still the master.

Does this change the L3 context used to route the ICMP error when
resolution fails?

neigh_invalidate()
  arp_error_report() / ndisc_error_report()
    dst_link_failure()

For IPv4, the path is
ipv4_link_failure()->ipv4_send_dest_unreach()->__icmp_send()->icmp_route_lookup().
icmp_route_lookup() calls icmp_get_route_lookup_dev(), which prefers
skb->dev:

	route_lookup_dev = icmp_get_route_lookup_dev(skb_in);
	fl4->flowi4_oif = l3mdev_master_ifindex(route_lookup_dev);

So the oif and the inet_addr_type_dev_table() checks now come from the
slave rather than the master.

For IPv6, icmp6_send() takes iif from skb->dev:

	if (__ipv6_addr_needs_scope_id(addr_type)) {
		iif = icmp6_iif(skb);
	} else {
		...
		iif = l3mdev_master_ifindex(skb->dev);
	}

icmp6_dev() only falls back to the dst device for loopback or l3 master
devices, so the slave is used as is.

A teql master can be enslaved to a VRF, since vrf_add_slave() only rejects
l3 masters, existing l3 slaves and loopback. The slave is normally not in
the VRF.

In that setup, the host-unreachable error would now be looked up with
oif 0 in the main tables, not in the VRF table that holds the master's
address. Could it then fail routing, or follow a main-table default route
off the box?

The same seems to apply to an IPv6 link-local source on the master. There
the strict oif=slave lookup would not match the master's local route.

Without a VRF and with global addresses, l3mdev_master_ifindex() is 0 for
both devices, so nothing changes in that case.

The commit message says the error path "names the slave on that path too".
It does not mention this change in routing context. Is it intended?

>  		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.v5.r0.20261116052927%40mojatatu.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net v5 1/3] net/sched: sch_teql: unshare the header before writing and fix retry strip
  2026-11-19 10:38   ` netdev-bot+sashiko
@ 2026-11-19 11:46     ` Jamal Hadi Salim
  0 siblings, 0 replies; 8+ messages in thread
From: Jamal Hadi Salim @ 2026-11-19 11:46 UTC (permalink / raw)
  To: netdev-bot+sashiko
  Cc: netdev, victor, jiri, davem, edumazet, kuba, pabeni, horms,
	stable, sashiko-bot

On Thu, Nov 19, 2026 at 5:38 AM <netdev-bot+sashiko@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> 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] This patch changes how teql_master_xmit()
>   (net/sched/sch_teql.c) retries when an skb has a dst attached and…
>

yes, this is legit. I will send a v6.

pw-bot: cr

cheers,
jamal
> --
>
> net/sched: sch_teql: unshare the header before writing and fix retry strip
>
> This patch calls skb_cow_head() in __teql_resolve() before the slave
> neighbour can write or queue the skb, so a cloned header is not
> corrupted. It also changes the retry path in teql_master_xmit(). The
> retry now pulls back only the bytes the current slave pushed, instead of
> pulling to the network header, so AF_PACKET frames without a dst keep
> their own link header.
>
> Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-6HS9.v4.r0.20261111094338-1%40mojatatu.com
> Link: https://lore.kernel.org/netdev/20260824115928.4099988-1-victor@mojatatu.com/
> Link: https://lore.kernel.org/netdev/20261110101908.2e64e8e9@kernel.org/
>
> > diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
> > index dc21cd9704a25..626dc001ec231 100644
> > --- a/net/sched/sch_teql.c
> > +++ b/net/sched/sch_teql.c
>
> [ ... ]
>
> >       if (neigh_event_send(n, skb_res) == 0) {
> > +             int off = skb_network_offset(skb);
> >               char haddr[MAX_ADDR_LEN];
> >
> >               neigh_ha_snapshot(haddr, n, dev);
> >               if (dev_hard_header(skb, dev, ntohs(skb_protocol(skb, false)),
> >                                   haddr, NULL, skb->len) < 0)
> >                       err = -EINVAL;
> > +             /* The bytes prepended above skb->data, pulled back on retry. */
> > +             *hlen = skb_network_offset(skb) - off;
> >       } else {
> >               err = (skb_res == NULL) ? -EAGAIN : 1;
> >       }
>
> [ ... ]
>
> > @@ -408,8 +421,10 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)
> >                       nores = 1;
> >                       break;
> >               }
> > +             /* Pull back only the header this slave added. */
> > +             if (hlen > 0)
> > +                     __skb_pull(skb, hlen);
> >               skb->dev = dev;
> > -             __skb_pull(skb, skb_network_offset(skb));
> >       } while ((q = rcu_dereference(NEXT_SLAVE(q))) != start);
>
> [Severity: Medium]
> What happens on retry when the skb has a dst and already carries
> link-layer bytes in front of its network header?
>
> The old retry reset skb->data to the network header. That matches what
> neigh_resolve_output() and neigh_connected_output() do before building
> a header:
>
> net/core/neighbour.c:neigh_resolve_output() {
>     ...
>                 do {
>                         __skb_pull(skb, skb_network_offset(skb));
>                         seq = read_seqbegin(&neigh->ha_lock);
>                         err = dev_hard_header(skb, dev, ntohs(skb->protocol),
>                                               neigh->ha, NULL, skb->len);
>     ...
> }
>
> __teql_resolve() pushes the slave header at skb->data without pulling
> to the network header first, and hlen only counts that push. So with
> the new retry, any L2 bytes already present when teql_master_xmit() was
> entered stay in place across every retry.
>
> One path that still delivers such an skb, even with the rest of the
> series applied, is nft fwd ... neigh on a netdev egress chain.
> nft_fwd_validate() allows NF_NETDEV_EGRESS, and nft_fwd_neigh_eval()
> neither pulls to the network header nor drops the dst:
>
> 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);
>     ...
> }
>
> teql0 has no header_ops, so arp_constructor() installs
> neigh_direct_output() for it:
>
> nft_fwd_neigh_eval()
>   neigh_xmit()
>     neigh_direct_output()
>       dev_queue_xmit(teql0)
>         teql_master_xmit()
>           __teql_resolve()
>
> The skb arrives with eth0's header in front of the IP header (network
> offset 14) and eth0's route dst still attached. Because dst->dev !=
> slave, __teql_resolve() looks up the slave's neighbour. From there:
>
> If the slave neighbour is resolved, dev_hard_header() pushes 14 bytes
> and hlen = 14. If the trylock then fails or the slave returns
> NETDEV_TX_BUSY, the retry pulls only 14 bytes. The next slave sends
> slave header + eth0 header + IP, while the old code pulled 28 bytes
> and sent a single header.
>
> If the slave neighbour is unresolved (-EAGAIN, nores), hlen = 0 and
> nothing is pulled. The next slave in the same pass gets the double
> header, while the old code pulled the stale 14 bytes.
>
> At this commit alone there is a second trigger: an arp_queue skb
> drained back into teql0 after neigh_resolve_output() wrote an eth0
> header. Here skb->dev = slave is only set inside case 0, so the parked
> skb still has skb->dev pointing at teql0.
>
> That second trigger is closed later in the series. "net/sched: sch_teql:
> keep skb->dev consistent on the arp-queue path" sets skb->dev = slave
> before teql_resolve(). "net: neighbour: reinject a parked skb through a
> headerless output device" only reverts skb->dev to a headerless
> n1->dev, whose output is neigh_direct_output(), so no header is written
> in that case. The nft fwd path above is not affected by either change.
>
> The AF_PACKET case in the commit message only seems to need the
> dst == NULL early return in teql_resolve(), where hlen is always 0.
> Would it work to keep pulling to the network header for skbs with a
> dst? Another option would be to pull to the network header in
> __teql_resolve() before dev_hard_header(), as neigh_resolve_output()
> does.
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-6HS9.v5.r0.20261116052927%40mojatatu.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-19 11:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-19 10:38   ` netdev-bot+sashiko
2026-11-19 11:46     ` 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-19 10:38   ` netdev-bot+sashiko
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
2026-11-19 10:38   ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox