🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21019

[PATCH net v3] net/sched: act_ife: return -EAGAIN after dropping rtnl_lock in load_metaops_and_vet()

#21019
From: YanXin Li via B4 Relay
Date: Mon, 23 Nov 2026 13:31
106 lines
15139 bytes
From: YanXin Li <fadouse@pm.me>

load_metaops_and_vet() unlocks rtnl_lock() to invoke request_module()
when an IFE metadata provider module (such as act_meta_mark) is not
yet loaded, re-acquires rtnl_lock(), validates the metadata attribute,
and returns 0.

Returning 0 after dropping rtnl_lock() breaks the RTNL serialization
relied on by filter-replacement paths in classifiers such as cls_basic,
cls_flow, cls_fw, cls_route, and cls_u32 (the existing-filter branch
in u32_change()), which hold an unrefcounted filter pointer across
tcf_exts_validate() -> tcf_ife_init().  In cls_basic, a concurrent
RTM_DELTFILTER can delete and RCU-free fold during the unlocked
request_module() window, after which basic_change() executes
list_replace_rcu(&fold->link, &fnew->link) and queues a second
deletion on the freed filter.  Generic KASAN reports:

  BUG: KASAN: slab-use-after-free in basic_change+0xf4c/0x1220
  Read of size 8 at addr ffff88800e043c58 by task test_act_ife_rt/101
  ...
  Allocated by task 101:
   basic_change+0x1e0/0x1220
  Freed by task 57:
   ...
  Oops: general protection fault, probably for non-canonical address
  KASAN: maybe wild-memory-access in range [0xdead000000000120-0xdead000000000127]

Other TC module autoloaders that drop rtnl_lock() during filter
updates (tc_action_load_ops(), tcf_em_validate(), and em_text_change())
return -EAGAIN so tc_new_tfilter() and tcf_action_add() unwind and
replay under a fresh RTNL critical section.  (In cls_u32's new-key
path, the error unwind in u32_change() still accesses an unpinned
non-root hash table in idr_remove(&ht->handle_idr, handle); that is a
separate pre-existing cls_u32 issue also reachable via
tc_action_load_ops() and is not fixed here.)

Manipulating TC filters requires CAP_NET_ADMIN in the target network
namespace, which is reachable by an unprivileged local user inside a
user and network namespace when CONFIG_USER_NS=y, CONFIG_MODULES=y,
CONFIG_NET_ACT_IFE is enabled, and an IFE metadata module is not yet
loaded.

When load_metaops_and_vet() drops rtnl_lock() and loads the requested
metadata module, drop the module reference and return -EAGAIN so the
caller unwinds instead of continuing on the success path with stale
pointers.  With this change, the same concurrent RTM_NEWTFILTER and
RTM_DELTFILTER sequence on cls_basic cleanly loads act_meta_mark,
replays without touching the deleted filter, and completes with rc=0
and no KASAN or lockdep reports.  A finite two-thread state-space
interleaving model of the cls_basic filter-replacement scenario found
the old use-after-free and no use-after-free, double-free, or deadlock
in its reachable states after the change.

The vulnerable code is present in upstream mainline v7.4-rc3.
Runtime verification and fix validation were performed in an x86-64
QEMU/KVM guest running mainline after v7.4-rc3 with Generic KASAN,
UBSAN, and lockdep.

This issue was discovered through LLM-assisted code audit and manual
code inspection of net/sched/act_ife.c.

Fixes: ef6980b6becb ("introduce IFE action")
Cc: stable@vger.kernel.org
Signed-off-by: YanXin Li <fadouse@pm.me>
---
Changes in v3:
- Remove the comment from the module-load retry path (Stephen Hemminger).
- Clarify the scope in the commit message: note that cls_u32's new-key
  error-unwind access to an unpinned non-root hash table in u32_change()
  is a separate pre-existing cls_u32 issue also reachable via
  tc_action_load_ops() and not fixed by this act_ife change.
- Link to v2: https://lore.kernel.org/r/20261122-b4-02-act-ife-rtnl-uaf-v2-102eba468698-v2-1-67c413c45928@pm.me

Changes in v2:
- Resend via b4 because the archived v1 email has a corrupted diff and
  cannot be applied.
- State how the issue was discovered and clarify the finite model scope.
- Link to v1: https://lore.kernel.org/r/20261122030728.9368-1-fadouse@pm.me
---
 net/sched/act_ife.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 5a527da0056..68a111c7f86 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -275,6 +275,10 @@ static int load_metaops_and_vet(u32 metaid, void *val, int len, bool rtnl_held)
 		if (rtnl_held)
 			rtnl_lock();
 		ops = find_ife_oplist(metaid);
+		if (ops && rtnl_held) {
+			module_put(ops->owner);
+			return -EAGAIN;
+		}
 #endif
 	}
 

---
base-commit: c44104f3642da720164042623e4832836aefdd8e
change-id: 20261123-b4-02-act-ife-rtnl-uaf-v3-3e43796c4fc1-85026ee8d92d

Best regards,
--  
YanXin Li <fadouse@pm.me>
Technical Details
Message-ID: <20261123-b4-02-act-ife-rtnl-uaf-v3-3e43796c4fc1-v3-1-93fa0f782cf4@pm.me>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369406-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369406-linux-kernel-netdev=dewy.ru
From: devnull+fadouse.pm.me@kernel.org (YanXin Li via B4 Relay)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v3] net/sched: act_ife: return -EAGAIN after dropping
 rtnl_lock in load_metaops_and_vet()
Date: Mon, 23 Nov 2026 21:31:27 +0800
Organization: Usenet Network
Message-ID: <20261123-b4-02-act-ife-rtnl-uaf-v3-3e43796c4fc1-v3-1-93fa0f782cf4@pm.me>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="3889346"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:FudGpPV/dJFnJlMpPPYV6IUzmdw= sha256:uNxedj+1igO78kwDixzbMT5YLfQX9/g3Lrjh7xd64xE=
	sha1:XvQ5dUijtY9k1JmIdAmtgQNb/Pk= sha256:5FI7v5l/e9hi9V+up3Zeemm+gudfkvin6tILgYGcreI=
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 02BD8125DB3; Mon, 23 Nov 2026 16:32:30 +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 FEOPHhMjRamu;
	Mon, 23 Nov 2026 16:32:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369406-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 93D3D125DB2; Mon, 23 Nov 2026 16:32:11 +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 174F72DAA2; Mon, 23 Nov 2026 13:32:09 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795440728;
	b=Ye1cRKL0+w+GOoitjLBg7naVUAvr/4kZUMFrab1ksBesJwZXFRpwD7uOGJuVA2swT4Rv
	 vYhpyJ9Rt4NWgUYb5Kx9XFpOQFDTqL+lPbuJp92gw9WzRuEGqZ/LvrTOKglJLHdXRDbwi
	 zmxjED2un/G0nkCU8jKQaZzgkGhzw+MqbJx1IHn7ua1LK2HaVUGlXHlWwbT4EmNWJtyJ5
	 kd8HnzxqcTuBZn5yVk8g5D+s1oCvfL74YIZ7+aYI9/OI2oKtNHymkl4tIndAVvu2XBCW5
	 FhtbZ+GqcVjW6tzkj9NJlBNmfsKlNdzuKlAzKDC4NxTzPpmHLsuX/FVfyeKQVQVKOBA==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795440728;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date:
	 Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=g1CW7c3pTtOr8mmmjYe30pIrbe4DRRxUC8YCS/6YhX8=;
	b=4xHWUTIFK3KhlMeNCZRprrOs+80exgLSRiKJJR9O+bsYsB8nx5bsDtDswtxYHqRSScsz
	 /cFb2QlY7ZjanS1hv6W/aUl/al96BwZvZDf7NWPS7OYeJlyBfu6yC2x3HMHId11YfiTt+
	 WZR3sDHS5A+wjl93K97b9e7Y4Ox7UsIqwtcUxIF3S0I1GecRR6nFsS2x9OLOnYRuLw1Qe
	 7WDrq/q2I689QCJ1wyqSC2FzhSm3sy+f+QFNAI/LiRy7R8No/u9ikXq+6LolX/+THWoo5
	 nmaZ5oByhEiyeEJBG8WgAQUvn2PerSDVyi9U2i0hHDtRt2MJNoKNL1nmaVdgtUy/LvA==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lEdirOts;
	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 C6DAC606A330;
	Mon, 23 Nov 2026 13:32:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lEdirOts
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795440723;
	b=QRRemA5aEaJWoe2QIrcnHBsgzx8PfV0E4BCEy2d304K5VuOFfFAXPFUHPsQ7WpKE4YPT
	 +Kb0a2T+v3u1Rs21Jh2LH/ln4lV8DqG0UiVLEnUGGB4V373LR6IKhj2s5hy5MXTz811MA
	 24o7uR6KLBKtSxiIQ/JIqPPy7F66U6/ddPNYfLPocqrtvqBW1kKz85K8Je1kT5s5mGSpk
	 Wv9oYycFlG3hCsiJtc8f0HBC5VcsIJoBvrWux5ajEAbFdwpyIGADLcHO4WyB2zxXIuUIh
	 NSn/SdTwcgd5SAzpDQWPbe/AJRef8j/b7wHPAXjhsJ61k3x7wIlwymkIK8ooiEtTP3g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795440723;
	h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version:
	 Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=g1CW7c3pTtOr8mmmjYe30pIrbe4DRRxUC8YCS/6YhX8=;
	b=fTYO1keQs5xFAexItTgdh2SyU8zMAAzQs3tdB/XZvXBR4AheS7hUb3o4pzsPbzlooWn7
	 /TAfNCjzqpNk+D+EfrPPthsEC8ugdlYGFJL+xWWEqfGKVdj+wCZHhjU0qf6RiiDBUo4SM
	 /8XpsJzzhjPNWjrWK77TE5ezZtR+8Px1vcJcR1/UBgkjAqFIvAVhO4waQZlSnzaUcVgNT
	 Hk2PIPZjWRRAVBa0E309La5qFZgh44Ike8La3QnbXSu5mYX18Ye6wLwIfOayW9zZN4Xcd
	 GszOCgd14B3UrU1EI6Z6QRNSkEzgP1ORQfJmOb8TQv45l9lhDBdfjekoo6tppvN6DNw==
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=lEdirOts;
	arc=pass header.oldest-pass=0 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 E1BA6606A31A;
	Mon, 23 Nov 2026 13:32:02 +0000 (UTC)
X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77
X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none;
	t=1795440721;
	b=cIbLgxa87NkmEWFtvh1RYYIkV8zCaDO3tf35up4bhRwowsDtv/mhnjDL1qKmfEovFIcD
	 sN5v24Ka0ZyQsstw+w4bCrXeaaGzBP0sFywD0vZl+Cd1wh12CDJgJ6RyQuoHRwiw5G8Y9
	 dGCscMx3DH5IZ6wYwnb4rfM8wvf08uN6YEnNxOinPcYNCTuNtpC6x3QTsqOqAY6S/wFmT
	 cgCgxDY4+d4XWyZrZSuG97zqVJ0gIXUods5wyczjB5GAXI9ZWb1ZeDCo5kPaIYmFKnw89
	 3znnBTH76ATt5CvAqQHrt5EmO8qlQHGCVtU7AnokMpH49uOH2lTVyX8BjFcuyokskmw==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
	c=relaxed/relaxed; t=1795440721;
	h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type:
	 Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=g1CW7c3pTtOr8mmmjYe30pIrbe4DRRxUC8YCS/6YhX8=;
	b=adT1xPcSo4ASx3Rt28rtTyiMgplvkuB37+IwHQ3Sq1ix+i8/u3x+MVtrRx2b+PrYE4aL
	 Kv8zCGSj+GA0gwRHMeU+VPnqpX//GfP1BYu0Zc0BGqLb6BnJK8gbaAuY10+k8uubi1hr/
	 mkD6IP/xDU6lMdraRZsIL9LRx9o7bPht5W5HUzje7ZMUUXj8taKv4gc0jjbAmel9kCioo
	 zUOQh2ZfmSJpk0hQZMTOd5HSKtz071RA2KCnSb6ZDiGU4ruxMd6KH8fz+Bg/4LRK3ht6z
	 KPCRP7vJP4MBbwuozPc0mUnguwoAPTZaxmJB3JlkNoB88a03uOIQyO+DkQpbI451jjA==
X-ARC-Authentication-Results: i=1; smtp.kernel.org; 
	arc=none smtp.remote-ip=100.80.115.77
X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.kernel.org (Postfix) with ESMTPS id 4A32F1F000F0;
	Mon, 23 Nov 2026 13:31:47 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795440721;
	bh=g1CW7c3pTtOr8mmmjYe30pIrbe4DRRxUC8YCS/6YhX8=;
	h=From:Date:Subject:To:Cc:Reply-To;
	b=lEdirOtsvCvnMJPG2B5gMKMUuROpavmQ5irWgY3/20XIAAlu/Ix+gKGFHTx+HFem9
	 wgVNaYGqt9ggglTcNUDjEzbamzEGwrT7pGv9uBDefL0U1dTlU/zmeLmZ3F2GnqPeSY
	 ci9byydjfN3n21AUBI2jBUSVbUZOucjpoFoyCoHRfaEOFBfOPjsCsJUnVVVq8l47FY
	 yaxn3b9OZBfp+UkptXYUrcRA86/A4xkwk76hFVcZSNCkaRNgdZH7fcMm0vxTvYbpLT
	 A/PGP8h7XK59W4rXgdEBm63GOtXW2+ULvNQc6kJZJMcYh9tJxxiCurIyDhg29o/qb0
	 kAhjElLqwF/bQ==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
	by lkml.kernel.org (Postfix) with ESMTP id A3A9F4C490;
	Mon, 23 Nov 2026 13:31:46 +0000 (UTC)
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-B4-Tracking: v=1; b=H4sIAC5ABGsC/yWNQQ4CIRAEv2Lm7EQYRkS/YjywMCjGoIHVaDb7d
 1k9dqW7a4ImNUuDw2qCKq/c8r30YNYrCBdfzoI59gykyGpNBgdGRejDiDkJ1rHc8OkTvgwaYbP
 b28ApaHTbPhBxcU8R+tmjSsrvn+gIRUY4/WF7DlcJ46JYaoNvgkP1JVwWVOXmP7jATWDWipOxT
 NHvSGnLislStzpDzlgvKUYnMM9fUwmc+dUAAAA=
X-Change-ID: 20261123-b4-02-act-ife-rtnl-uaf-v3-3e43796c4fc1-85026ee8d92d
X-Cc: Simon Horman <horms@kernel.org>, 
 Stephen Hemminger <stephen@networkplumber.org>, netdev@vger.kernel.org, 
 linux-kernel@vger.kernel.org, stable@vger.kernel.org
X-Mailer: b4 0.16.0
X-Developer-Signature: v=1; a=ed25519-sha256; t=1795440705; l=4563;
 i=fadouse@pm.me; s=b4-relay-20261122; h=from:subject:message-id;
 bh=7DHuyrQLhOeh9C5+PXyUekYvXmy1gMXBow6B9d9EIpY=;
 b=1ARe0+Az5wJGRagyMXgOjGKai5/2m6h4b0FcYuzsb5AL2bAT0wVmNFWD69XnvNlEasGTz2Q9R
 WtpyrwXlWr2AbLDbshhL8ae16cOQ5oZEzijJhcxv7WbtP2mqpFp+3vy
X-Developer-Key: i=fadouse@pm.me; a=ed25519;
 pk=b4DyzHJDRd8853IHUSKPA5wwzChj8eF4MTnZuyPz1PQ=
X-Endpoint-Received: by B4 Relay for fadouse@pm.me/b4-relay-20261122 with
 auth_id=1597
X-Original-From: YanXin Li <fadouse@pm.me>
X-Reply-To: fadouse@pm.me