🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14600

[PATCH net v4 3/3] net/sched: sch_teql: keep skb->dev consistent on the arp-queue path

#14600
From: Jamal Hadi Salim
Date: Wed, 11 Nov 2026 15:17
142 lines
16013 bytes
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>
---

v3 -> v4:
- Move the net/core/neighbour.c change out of this patch into its own fix,
  as asked in the review. The sch_teql change is unchanged. Considered
  comments from Jakub Kicinski.

---
 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 3f781a3ffb41..2a8383546ce8 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -373,13 +373,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
Technical Details
Message-ID: <QDISC-6HS9.v4.r0.20261111094338-3@mojatatu.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361143-linux-kernel-netdev=dewy.ru
References: <QDISC-6HS9.v4.r0.20261111094338@mojatatu.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361143-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v4 3/3] net/sched: sch_teql: keep skb->dev consistent on the arp-queue path
Date: Wed, 11 Nov 2026 10:17:30 -0500
Organization: Usenet Network
Message-ID: <QDISC-6HS9.v4.r0.20261111094338-3@mojatatu.com>
References: <QDISC-6HS9.v4.r0.20261111094338@mojatatu.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="885354"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:a9u+hKapU9ZpyFbX1197lO8HGHU= sha256:FM3Br3WkLEDWN/yIEuUBi3IOHuHyclXVlFlFkJ6BeAA= sha1:/9Y5RTKLuuRZrS557DGwxLVQldI= sha256:3PWbhCb5vlTKrwzYnAOnpLYeYLamHRRNP+hXmPsZygo=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 2BA37113F3C; Wed, 11 Nov 2026 18:44:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=mojatatu.com
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b4r5E221Vwky; Wed, 11 Nov 2026 18:44:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-361143-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 5E148113F35; Wed, 11 Nov 2026 18:44:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 93D98182FDE; Wed, 11 Nov 2026 15:17:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794410262; b=V+XCVBJ2FOC0r1PclD4Gs5gPxSRymDlFXOET3zVo9pbS1Xw3FAglzHrxTqYZ6nWyp9QZ ap/e97UrjFo12ia83NPygOVNNi/YBJzonKUOLlAhkfe7Q3POA9Jwm7mJxfhvd75zJX+Bo BfIEmqp1mp0haxEQsBK6SWB8po3EWMFUaVbd0djJH0gxXk6ZoKrEXe6MaWE0SVjRNsYZg XNZrPiHGsjkqhrJCguBG1UKReasWitR6l9Wqe2rzbQJtvE0m7habG/jDYPGIKQoT+lhEq 1gPeGaYB9zhNqRuzZoCaxyQ7agYwEniVF1OJCJi25DnhyeNJYjJNMmzXDcaB8t8+h4g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794410262; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received: Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To: References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=Fb1BuTd8Qdd5dScIxIahcjCU39aHCzq4j68dvvRT6cI=; b=XsnFFCSdp+UjaNdjTVWYrw6ADna49YHxeN2rSq7OB6BkiXxnK7eBCPM8ewtvXpLM9mWu 1TMZ9PnJPI+sOFCFadD+VAGJmIu73sMLtaqxvdM79m6esBs+NFhpkeIuUkBZREjmsyrie r8ylV/LaS7g3TeuvwHTY8c7x/t9Z/uaZXwzfT1ulJoMMJz/2M4nT416QYxJZ7Lpg+vyVZ oJQkErvkk0noZTSQE8LU3Kde8H9gk0p0wYbeiC11416HYZJqejJxNT0z78oEKzK4nabhV yyPOzA3AWQxEAqtzN7xIlKKnB9ThSKV+hjHusC6jNzo9d3CxEincPA/9pjEI7SGl1CQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=UkDLMs4f; dmarc=none header.from=mojatatu.com; spf=none smtp.mailfrom=mojatatu.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7503606A33A; Wed, 11 Nov 2026 15:17:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=UkDLMs4f
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.177
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794410262; b=A91wkS9PbbT2KYMy9aPa2QqE8jo7m41Fq+755tl5MEJZBYR8Nuy6SrsUENzQtFNwPHtL xnhFsEdS7rGihRd6rLVBBpI/FglSm3hsJgpXQzgazn/UpHKIL/+FoLPOoMt1MuYHg7Z7+ KOVI+YXTAUe6QNEohKHh/cF0mzZlNIdxpmman/nTTmdqrA8BUQahJ00y2W8Rz18trbSEi DNOmireLY3QWe8xyk5RIlbB70DLlnea0wL7xSFdptP2ucurj/9mCQxr2A31uYvuBvaqMq kyaspLAY8cTaRmb051nJl65X8MrPjGWTm33Bc7sL9zPGyRpbpRkJDCrjNs+3Cj7B7Ig==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794410262; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=Fb1BuTd8Qdd5dScIxIahcjCU39aHCzq4j68dvvRT6cI=; b=k/MmWOpE7y/XTIhd8iGJ7LvvPUvNetod91+HMjcYKCuFxQbc/8XAcb89kdjJNb/cBv94 VrGQpsziBcf9VK4YSAckrmzQ6le+xSebVS6K/i0R7kglyzbd+cq60+CnmAvwSO+VWCd3y fJKfW25DL4gtns+wEBPesdAfDUSHIu+n47mTsnY+tu7w1EtZWjyTSey5tUNOs1CLtsNR4 xr3nfFK3JsfkleDIj+7twCPKCQ0RWxL4aPMGWjgo2SSDYADHA0RGWZtsEPRKU/JrqgXko 5yee42MLN9luMWAfMgZ9E8ZWVGSuXenv1k+sjNoego0JhiKS+KXbgLyTG480v/0xLDw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mojatatu.com; spf=none smtp.mailfrom=mojatatu.com; dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=UkDLMs4f; arc=none smtp.remote-ip=209.85.128.177
X-Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5809A606A898 for <netdev@vger.kernel.org>; Wed, 11 Nov 2026 15:17:41 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5809A606A898
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com
X-Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-8b308fca7c3so32958857b3.2 for <netdev@vger.kernel.org>; Wed, 11 Nov 2026 07:17:41 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu.com; s=google; t=1794410260; x=1795015060; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Fb1BuTd8Qdd5dScIxIahcjCU39aHCzq4j68dvvRT6cI=; b=UkDLMs4frWeJNsVGLmw41nhNjVIS3eyumrw5kd1oiFdJ9939nYam6wsR9/3XYbhIpf ZnVsORTMkhHXMgPoYzpdVCYR1T4QRPxBGSwuvLzntrDl8tfuURXa5oSqJwnlkDL4z1IP lz7aJEwC10IMM2TMHQZILjgXJeB7MJeB32fKY=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794410260; x=1795015060; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Fb1BuTd8Qdd5dScIxIahcjCU39aHCzq4j68dvvRT6cI=; b=g8yAE5xJ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kfCrnYf0fo6N9O2NNAuNIkt ndvkIxNUwLNKnn9iBsLjzVqQvqwrowdbu+ySGGJeAdVavad5/65axmvVEiNNmY4Sv9rvh3/S9kD zyCEgUP/odh5czw==
X-Received: by 2002:a05:690c:113:b0:8b0:ecb2:883a with SMTP id 00721157ae682-8b3a81d7fdbmr20123797b3.62.1794410260356; Wed, 11 Nov 2026 07:17:40 -0800 (PST)
X-Received: from localhost.localdomain ([64.203.83.2]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b393409120sm46499187b3.27.2026.11.11.07.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2026 07:17:39 -0800 (PST)
X-Cc: Jamal Hadi Salim <jhs@mojatatu.com>, Victor Nogueira <victor@mojatatu.com>, Jiri Pirko <jiri@resnulli.us>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, stable@vger.kernel.org, sashiko-bot@kernel.org
X-Mailer: git-send-email 2.34.1
X-In-Reply-To: <QDISC-6HS9.v4.r0.20261111094338@mojatatu.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Received-Bytes: 15727