🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17050

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

#17050
From: Jamal Hadi Salim
Date: Mon, 16 Nov 2026 10:36
135 lines
15976 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>
---
 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
Technical Details
Message-ID: <QDISC-6HS9.v5.r0.20261116052927-3@mojatatu.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364198-linux-kernel-netdev=dewy.ru
References: <QDISC-6HS9.v5.r0.20261116052927@mojatatu.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364198-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v5 3/3] net/sched: sch_teql: keep skb->dev consistent on the arp-queue path
Date: Mon, 16 Nov 2026 05:36:43 -0500
Organization: Usenet Network
Message-ID: <QDISC-6HS9.v5.r0.20261116052927-3@mojatatu.com>
References: <QDISC-6HS9.v5.r0.20261116052927@mojatatu.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2035830"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:tGCZ0YVFSs5NABKCpJOHz2Pl4NU= sha256:mYwlSjDdUIratqS4Q8CHDalzh+7TDVzJWcT8RF4qid4=
	sha1:RdsJDebyY5XQJLQ2l2YzNQ1E7ks= sha256:M2s4+RrX6APadMmD2UQlxHr5V6XRhqJo3wW3t1encrA=
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 5CF2B114B9F; Mon, 16 Nov 2026 13:37:26 +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 NpRKJWgD7Uhy;
	Mon, 16 Nov 2026 13:37:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364198-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id E9C40114B9B; Mon, 16 Nov 2026 13:37:13 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 0C7662B810; Mon, 16 Nov 2026 10:37:05 +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=1794825416;
	b=Tb17ycif0EUJn3LlJQ5QPb/4Oz3iyvbuakbD/i0z12C1UvlVP7qaSRMQ4UC+nh9yMlV8
	 7YW8oZGTSR0qq+BAhL8DeJ7bJUG9tFhKgqditpWKaFfG0VUs15LRoUJ2Y2A1e14AHEJc1
	 /dkORxnMzsEMOqBAE8ZgHNikVT28NOAYYq/m+RpNh1lWEvahtmK8F5R1aSVs8o3n9V5fK
	 u89ULRuCyZcURpNjiIy1XKzdKE1ncqymPNuv6JXWuuFVZki0EvCaNeF0N3lDWWouJB12e
	 ZMnrtIoQX2l/f5aFoQZdX9C6IMMBQOmYbGfQklrV2tJErMk0L7WDiNcqGSGpnGcSfoA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794825416;
	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=LX0+DV+LDSGdBcKNRc1D1pjJHJmtAjduSSHWyN3x/kE=;
	b=B/cLNYQUgq1yUaJ7dQ2eYFcU2ELZ7l0FA2j2iBO/gjuVrATeIQi5d4s/yYIPhR05bGic
	 QVXvpXQX9lezzu01gXj0qGTSYWxzjRNYSE4YHK0qWJvJp9QuenR3hFfgOY9rs+K1kqlTB
	 SFuWSxuVBfQrzIgXHX3JtDIOAnkXWplfwH5mZFY3gd4Xe+WvU8IPfFejtf6L8MNLjDxoa
	 bL/CdB+/KmdOFrYcQoYQsMW7gqALkIg5zaG/Rbf30e/8L8uUOhzKYED+KzVVnJNGQTCYl
	 +U1kA/Xs7zkzC+GWEJIlbhu8ovzXvHFUxwycDllR2gO2hx7tDZG1DW71UGDmO0NevZQ==
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=BPsMS9D4;
	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 E6C55606A31C;
	Mon, 16 Nov 2026 10:36:55 +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=BPsMS9D4
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.177
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794825415;
	b=TICWB+pziD/5TBwEB38f+nSmITZHb7q04pJUAl3Jn0/EnZH/p1lvDvttOahHXCbllNqf
	 wlPlcwOWNCMq9u1i6UMXQGNJ64muO2e6Uf7tDR5V+h6Upx/kwVns0HfjYjLMhAzhHTQ9a
	 lZDxt6swnhGvJpLbx/g/XIw4WQ1D4AbHNM5I6y5h8hOnO+AtQYGvOS6ZvX1Zr5UorKBzF
	 9gAcK6UYgBrSGJUAYir79fWwzsotBBubQcuXfF+BGxkCPhmvJAwFQysOEV6u0YnOvJXWt
	 HzlZ6uPgOeRcmK+Dzfo5DGtFXe9rJhC38a7XmaqjdQIN4wVZoq4HkVZUTxjGH2/CIOQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794825415;
	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=LX0+DV+LDSGdBcKNRc1D1pjJHJmtAjduSSHWyN3x/kE=;
	b=ImXnyaJvqe3EKCrxS7/TttEgeD1HO2ySw0n7u0scSui9z7mLouY1i1xqEMbId9Xosu7P
	 fvtCsdKnL+yP+LY4WmascjgDLycBJik8Ua8c/9jqhp6fvukZ5ya1/BGHwZzB9Rg9XPwyk
	 1+qTOXezq4P6+zxB+a2SB+wbCxpP36kqhQ+eVKBEYD4Zk/fe9xKmfKEhU8LbhQ501Zy4N
	 +t5bceoFa2P2Yy1DZeFMsAqEOf1+CnjbSZ03l3IJ7Ht6lfLLxvWL/XeALS/BIEyrLfI26
	 XYHpEnQK8aEvhF7HJkGkzAqFanrE4GP/0sKvouUFmFVYtjEDCb787LxPlLeeRsIoEgA==
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=BPsMS9D4;
	arc=none smtp.remote-ip=209.85.160.177
X-Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.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 B83F2606A8A5
	for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 10:36:54 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B83F2606A8A5
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-qt1-f177.google.com with SMTP id d75a77b69052e-55ade1de0b4so45451211cf.3
        for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 02:36:54 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=mojatatu.com; s=google; t=1794825414; x=1795430214; 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=LX0+DV+LDSGdBcKNRc1D1pjJHJmtAjduSSHWyN3x/kE=;
        b=BPsMS9D495KNtTcUwPLACacoKGxzzcVgbGDBwMzc0rfXnIecz4GUgdjT+nxdKBTr+u
         1+egacBy5IbNmDhSBkl87nDI2uikwsMRELO+HoqCgxx0/40/Q9WM2xxYYvOvMMxogpHJ
         m2LRw6bTfw1dvZJ12Z2tMNqzVK9GDcEdFHXqM=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794825414; x=1795430214;
        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=LX0+DV+LDSGdBcKNRc1D1pjJHJmtAjduSSHWyN3x/kE=;
        b=NpFoWZSnjxFDeQs5y8kaXtQsmPvgZ97Zz1Ih60W4qzbNFaCv9C7ZqdUSc4yudIvSTm
         U1wsnZyZFkkTF3nKnfo2LrtFRpCcYIMozW3ogI4P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SXdCKQteWYJGos
	=
X-Received: by 2002:ac8:5995:0:b0:55d:2caf:ae7c with SMTP id d75a77b69052e-55d2cafb009mr79499971cf.19.1794825413577;
        Mon, 16 Nov 2026 02:36:53 -0800 (PST)
X-Received: from mbili.waya ([64.203.83.2])
        by smtp.gmail.com with ESMTPSA id d75a77b69052e-55ad14f1ecasm77778651cf.24.2026.11.16.02.36.52
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Mon, 16 Nov 2026 02:36:53 -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.v5.r0.20261116052927@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