🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8266

Re: [PATCH net v2 1/2] net/sched: sch_teql: fix slaves_lock IRQ deadlock

#8266
From: Simon Horman
Date: Wed, 28 Oct 2026 14:27
78 lines
12278 bytes
On Sat, Oct 24, 2026 at 10:34:14AM -0400, Jamal Hadi Salim wrote:
> This is a followup of commit e5b811fe7931 ("net/sched: sch_teql:
> Introduce slaves_lock to avoid race condition and UAF") as reported by
> Sashiko.
> 
> The issue: master->slaves_lock serializes the master's ring of slave
> qdiscs.  The control paths -- teql_dequeue(), teql_destroy() and
> teql_qdisc_init() -- take it with spin_lock_bh(), while
> teql_master_xmit() (the master's ndo_start_xmit) takes it with plain
> spin_lock().
> 
> netpoll_send_skb() wraps the transmit in local_irq_save(), and
> __netpoll_send_skb() asserts lockdep_assert_irqs_disabled(), so
> teql_master_xmit() reached from netconsole always acquires slaves_lock
> with hard IRQs disabled.  On PREEMPT_RT spinlock_t is an rtmutex, and
> Documentation/locking/locktypes.rst names
> 
> 	local_irq_disable();
> 	spin_lock(&lock);
> 
> as a sequence that breaks there because the rtmutex requires a fully
> preemptible context.  This is reachable without any panic: the nbcon
> printer thread calls netconsole's write_thread() callback on every
> message.  The usual remedy -- folding the IRQ disable into the lock with
> spin_lock_irqsave() -- is unavailable because the local_irq_save() is
> netpoll's, not ours.
> 
> On non-RT the same asymmetry leaves slaves_lock acquirable with hard IRQs
> disabled on one path and held with hard IRQs enabled on another.  That is
> only exploitable during the panic console flush (netconsole is
> CON_NBCON_ATOMIC_UNSAFE, so console_is_usable() admits its write_atomic()
> only from nbcon_atomic_flush_unsafe(), which panic() alone calls), and
> even then an IRQ-saving lock does not help if the holder oopsed inside the
> section or was stopped by panic_other_cpus_shutdown().  So the non-RT half
> is hardening; the PREEMPT_RT half is the bug.
> 
> The Fix: take slaves_lock as a raw spinlock with IRQs saved at every
> site.  Since skb_queue_purge() takes the queue's spinlock_t and may not
> nest inside a raw lock on PREEMPT_RT, move its call in teql_destroy()
> outside the raw section; dat->q is the dying qdisc's own queue and was
> never serialized by slaves_lock, so the move is behaviour-neutral.
> 
> The new critical sections contain only RCU pointer assignments and
> netdev_get_tx_queue(); skb_queue_purge(), netif_wake_queue() and
> dev_reset_queue() are all outside them.  teql_destroy()'s ring walk is
> O(slaves), two pointer loads and a compare per iteration, so even a large
> ring is microseconds with IRQs off.  Keeping the purge conditional rather
> than dropping it outright is the conservative call for a backport.
> 
> Some context: commit 6301f6a34ed8 ("net/sched: sch_teql: move
> rcu_read_lock()/spin_lock() from _bh variants") hardened the parent
> fix; together they addressed the master->slaves resurrection
> use-after-free and the xmit-side BH warning but left the reverse
> direction -- a hard IRQ re-entering xmit while a control path holds the
> lock -- unaddressed.
> 
> Conditions to recreate the bug:
> - CONFIG_PREEMPT_RT, CONFIG_NET_SCH_TEQL, CONFIG_DUMMY and
>   CONFIG_NETCONSOLE.
> - Run `ip link add dev teqlslave0 type dummy`, bring teqlslave0 up, attach
>   it with `tc qdisc add dev teqlslave0 root teql0`, and bring teql0 up.
> - Configure a netconsole target on teql0 with explicit local and remote
>   IP addresses and a remote MAC address, then emit a console message.
>   The nbcon printer thread reaches teql_master_xmit() with hard IRQs
>   disabled by netpoll; taking slaves_lock as a spinlock_t is invalid on
>   PREEMPT_RT. No panic or concurrent qdisc change is required.
> - Reachable by an admin with CAP_NET_ADMIN; teql devices exist only in the
>   initial netns (no per-netns ops), so a user namespace does not suffice.
> 
> Fixes: e5b811fe7931 ("net/sched: sch_teql: Introduce slaves_lock to avoid race condition and UAF")
> Reported-by: Sashiko (gemini) <sashiko-bot@kernel.org>
> Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260630150922.238714-1-jhs%40mojatatu.com
> Link: https://lore.kernel.org/netdev/20260630150922.238714-1-jhs@mojatatu.com/
> Cc: stable@vger.kernel.org
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>

Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID: <20261028142729.GW257209@horms.kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352886-linux-kernel-netdev=dewy.ru
References: <QDISC-Y0BY.v2.r0.20261024060625@mojatatu.com> <QDISC-Y0BY.v2.r0.20261024060625-1@mojatatu.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352886-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 1/2] net/sched: sch_teql: fix slaves_lock IRQ
 deadlock
Date: Wed, 28 Oct 2026 14:27:29 +0000
Organization: Usenet Network
Message-ID: <20261028142729.GW257209@horms.kernel.org>
References: <QDISC-Y0BY.v2.r0.20261024060625@mojatatu.com>
 <QDISC-Y0BY.v2.r0.20261024060625-1@mojatatu.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="1790359"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Lj5Rqdq+DP0WcxJFdeWwQDhDB/w= sha256:qRgmB8qYgWWuhOxBMsEiTFh3qRaZItqHXy3DPFAB+L0=
	sha1:3v55iyhW510uYVCFsh3X2RnR97g= sha256:en5LyhOQBDIRglLd0+xkwYHsmKVffDZibRrEBJ3MfLY=
Content-Disposition: inline
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 431D6125C38; Wed, 28 Oct 2026 17:41:15 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
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 nFChwUYE5uDb;
	Wed, 28 Oct 2026 17:41:12 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-352886-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id E450F125C32; Wed, 28 Oct 2026 17:41:03 +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 956B12E95E; Wed, 28 Oct 2026 14:27:42 +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=1793197660;
	b=wv/DXgRbuxN8KesXik2WYXxXyMioH8bRlkAdDCrq+tBfuh4yNqcgVUSnr94nAi7r/R7T
	 VdjUFYUAsYletKJ0yjCusQeFmprYeu0kvnflexz7PPjeqv3nruEviMdtbS7oDHvBAETBi
	 31XC4PZA22uO8Pk6YDPf/r/Ed/QI5spGAiRDHcfVQNVsCZda33xmQ5tF3RbiJOaBI1aGa
	 SBqSPqtuFCZ56xwBiT5cldX2WhGFD+ILJAodtEH5B/Bdsp9FJsJm5ioYjxeVJV6eEB8pm
	 YLEY2Fs/2mOQXGrINuUmdOnonVMva1RrQEupUUYg+un+Ya8M4zPFzcukooUYn+HlxmA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793197660;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=LwivXIOL/bLE0FwSay+t1m6MvKvf0y7TbmImcg4RRU4=;
	b=O4Y+0zTDYzqwptbN+YoySnOLHGT/erjR46IirskRzqXxcWP1YV0ELvFV4xlAG/DxZS0j
	 KZb0PKpahQkDzul1Cxzia6OT2T5DbI2QmEN+ygCzL3PnHd+yjQYoVSO/Ltv42IEotvTTm
	 HwU1YRHyp2YW3l6Sve5Fg03xJg5SZJmo9ZFVJceHUvm29QtziZdpK/JrN6Q263suqUBzd
	 SPh5HA6BEC8qLLzwdP/HKejPKJgJX2xZx6aY/2IscwbNSOYvhiovMq5ehY38K7Ls+arBQ
	 8Lq3lL5Zjte3+Hf5uQjEP3pgL2WbNPy07+dkYdc//yWkm2aCHP9avQJ3CmZ/x5owyVA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZMOsBiX9;
	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 4473D606A325;
	Wed, 28 Oct 2026 14:27:40 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZMOsBiX9
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793197654;
	b=UwGobgPArgsf/1Pf/XH25pipbuL+Z5aaitamgw0NjRO/qg69X6KdBEmu6X1h7u1IULPG
	 mEPNq/mnIA5pASiNvWH8KlXWQ8Aqgqupw5IZfArnhJHtFKh9Vw0dh/LeHXecbmMxXYY8u
	 60akQFzNoyn0aceGnQ63FidVgnIa5tcnami0pzBwJOXvhLCuaW8+GMxu5h6BBPLdoLM4A
	 vX5O16rEAqz3HQA5Kt8iuJ5OxhDdB5zBehEc/CdifXKiXZ2a5mCmkGy6CXck5AT3AmPdQ
	 0Eo9zivvFWWSWVDV/hxBR323GsJnfMySODq93I+jiiR9/jADrhn09+apJoHXWKFHjbw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793197654;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=LwivXIOL/bLE0FwSay+t1m6MvKvf0y7TbmImcg4RRU4=;
	b=Q4AxYICy3tvQEIPSbzuUIiclNFHFhkH/6eIzIZQtOeAsvlRt5d4u81Z0nbNiUySDBhOk
	 +ol6gpLX58w6ZzNKxviGFUHJ64HjUEhm6Xeu6nihQQbcOfxb2WbcgPRGOcBVZ9ZvX79qP
	 BHNiirpO2r+1pl68exZVeHwas9tInMQCviQWHjkUI8c14x/m5PHH8C+HeioTqMMxQhm48
	 sLji8A0+e1g75s/4rGTcf6bdiX3sSAAMlxbxhxbhobv3rhIRabq4rdhC4l2R0iHdUroYl
	 7eDpDoKAhR2HuMhwch9q0AzHKpL+lDVFECJPKTst3HXKxj87nUHrifYy7Kvxi6GK1Xg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZMOsBiX9;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C771606A31A;
	Wed, 28 Oct 2026 14:27:33 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32A151F01825;
	Wed, 28 Oct 2026 14:27:31 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793197653;
	bh=LwivXIOL/bLE0FwSay+t1m6MvKvf0y7TbmImcg4RRU4=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=ZMOsBiX9GmoRctDsVY+OLUhIxW9NtvXwvcgyNDPish91vwxuAo87uubbrU7UYKZj0
	 T/BwQqEyMd7g0dws8obmw7BcLrMgqtvBaBgUlRlwoKjxgdhQ9vP4gK4IuNA9SET+rv
	 34yahmT51wLzG7v+uWtpdkvgCzv0Jp4yKU1wT+hvySmgZM7Uxj6Sn28nyxAdinkR4O
	 wrmoXWxe7W3OFaFjbXlub3SvS8+TgQh4YuzCsI739moisx1z47zNqr3pMqH0opC6wC
	 NqXTJcIk5t++GZBsVHIBPf1UDG8h+8WMQgRigU5pZ+761zpSLyYdn9Y/IT1RAP3JRA
	 elJbR4ALUuEBw==
X-Cc: netdev@vger.kernel.org, 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>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-rt-devel@lists.linux.dev, stable@vger.kernel.org,
	Sashiko <sashiko-bot@kernel.org>, zdi-disclosures@trendmicro.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-In-Reply-To: <QDISC-Y0BY.v2.r0.20261024060625-1@mojatatu.com>