๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20979

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

#20979
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 12:48
114 lines
11957 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท 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).

- [High] This patch does not fully close the use-after-free it claims to
  fix for cls_u32, one of the classifiers named in the commit message.

--

net/sched: act_ife: return -EAGAIN after dropping rtnl_lock in load_metaops_and_vet()

This patch changes load_metaops_and_vet() so that it returns -EAGAIN when
it has dropped rtnl_lock() to autoload an IFE metadata module and the
module then loads. The caller is then expected to replay the request under
a fresh RTNL critical section. The goal is to close a use-after-free in
RTNL-locked classifiers that hold unrefcounted pointers across
tcf_exts_validate().

> diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
> index 5a527da005661..5d6ca124e0047 100644
> --- a/net/sched/act_ife.c
> +++ b/net/sched/act_ife.c
> @@ -275,6 +275,14 @@ 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) {
> +			/* We dropped the RTNL mutex in order to perform the
> +			 * module load. Tell the caller to replay the request
> +			 * under a fresh RTNL critical section.
> +			 */
> +			module_put(ops->owner);
> +			return -EAGAIN;
> +		}
>  #endif
>  	}

[Severity: High]
Does this fully close the race for cls_u32? The commit message lists it as
one of the affected classifiers.

RTNL is still dropped around request_module(). The new -EAGAIN, and the
existing -ENOENT when the module does not load, both go back through the
classifier's error unwind before tc_new_tfilter() gets a chance to replay.

On the new-key path, u32_change() looks up a hash table pointer without
taking a reference. It then reserves a handle in that table and calls
u32_set_parms():

net/sched/cls_u32.c:u32_change() {
    ...
			ht = u32_lookup_ht(tp->data, TC_U32_HTID(htid));
    ...
		handle = gen_new_kid(ht, htid, &err);
    ...
	err = u32_set_parms(net, tp, n, tb, tca[TCA_RATE],
			    flags, n->flags, extack);
    ...
}

u32_set_parms() reaches the RTNL drop like this:

u32_set_parms()
  tcf_exts_validate_ex()
    tcf_action_init()
      tcf_ife_init()
        load_metalist()
          load_metaops_and_vet()

While RTNL is dropped, a concurrent RTM_DELTFILTER for that non-root hash
table can run u32_delete(). The pending knode is not linked yet and holds
no reference on ht, so the delete succeeds:

net/sched/cls_u32.c:u32_delete() {
    ...
	if (refcount_dec_if_one(&ht->refcnt)) {
		u32_destroy_hnode(tp, ht, extack);
    ...
}

u32_destroy_hnode() then calls idr_destroy(&ht->handle_idr) and
kfree_rcu(ht, rcu). request_module() sleeps while it waits for modprobe,
so a grace period can pass and ht can be freed.

When load_metaops_and_vet() then returns -EAGAIN, u32_change() unwinds to:

erridr:
	idr_remove(&ht->handle_idr, handle);
	return err;

Would this read and write the freed tc_u_hnode before tc_new_tfilter()
ever sees -EAGAIN?

The patch removes the success-path access to the freed table, which is the
ins = &ht->ht[TC_U32_HASH(handle)] lookup and the list insert. The stale
ht is still used on the error path, though.

tc_action_load_ops() also drops RTNL and returns -EAGAIN, so the same
unwind looks reachable through it too. Copying that pattern into act_ife
may therefore not be enough to protect cls_u32.

Could u32_change() hold a reference on ht across u32_set_parms() and drop
it on all exits? Alternatively, could this path avoid dropping RTNL at all?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122-b4-02-act-ife-rtnl-uaf-v2-102eba468698-v2-1-67c413c45928%40pm.me
Technical Details
Message-ID: <179543813406.3135.15745616872300382040@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369357-linux-kernel-netdev=dewy.ru
References: <20261122-b4-02-act-ife-rtnl-uaf-v2-102eba468698-v2-1-67c413c45928@pm.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369357-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] net/sched: act_ife: return -EAGAIN after dropping
 rtnl_lock in load_metaops_and_vet()
Date: Mon, 23 Nov 2026 12:48:54 +0000
Organization: Usenet Network
Message-ID: <179543813406.3135.15745616872300382040@kernel.org>
References: <20261122-b4-02-act-ife-rtnl-uaf-v2-102eba468698-v2-1-67c413c45928@pm.me>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3879145"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:bBPG1uIHsmdq06USXMCQ4AyxO9Y= sha256:z0ZkBeOoITXWdJaXH8CzPyBq9//KO0NdB/ExzeQ9hQk=
	sha1:eWCkU4qwTb3/AwUPyy13WY3VZDI= sha256:MYpzX1ZRd9QbfDKNX+EYSCKVzP3bYr19Vy4VghaA/8A=
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 4CFF8125DAA; Mon, 23 Nov 2026 15:49:12 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 NHUkOR3P-B1S;
	Mon, 23 Nov 2026 15:49:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369357-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 CD337125DB0; Mon, 23 Nov 2026 15:48:59 +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 86EC732626; Mon, 23 Nov 2026 12:48: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=1795438136;
	b=UtJ0VOJbtZTDe4q5Q7U+uEVrJ+uAF+qfFxj1T4Bg3XUaxBxCA/BpkpsTKbuBNtMoCyDw
	 Vs7zVfNkhjQOBhmrppFx26w29b/+U4Me6gJnQ+rzk9OWUh2v3CVqj125Q9SCgwCSWgG3V
	 xPAHqaiaNo7Jm+PsgvFUJ3XmLHwvCufCPT/4S/JbuaRwUVmhx2mPJmgY3E1bTEsrpu4Z4
	 VbeikAMGl1i4xwphMWVN135obcZEf+iQxR3sNO1HPChuSt1FoBu6JfMe5riguHVYOxmOd
	 k/eXDMfgTpFVNtVizd04C0n1hpbv84MU6HP1HuLaA45zOalB67HW+dd2itU1+8dOmew==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795438136;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=yI2Wo78/lAboL4lqhYNXgiMMUATpxcgIbU7d5ySHTsM=;
	b=bs1W7QNbz9VfnWwEuv6QBqgHK5XOJrEWrBeoobtlEjyXshHfHLjTZwRyCoIpsiykmYfa
	 nzfPh7lGWe/nVqgC1J6tE2ihj/aL0GNqofF9sjXN3SGD99EJzP7gsncSs3QJg20KAas5D
	 s0fec3BL8LhMNKhxWCXCh9a0yjn9e4yBPAygIZLqaxLKW/2qjEtakefg46ELhZG2XbhVg
	 347JDiP7s1s5nCs0BPx52GKuEyPieXClFnyefpoYyCGxpVWFSGZk2wS1/UKDrHsE/nja6
	 iLXq8TJWr/nt83mz4zKqJeuCE6g5ZtQQvzYOXdBF1beqFPPf/jVGeN/CowAdcfy0Rcg==
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=nilGTLgC;
	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 90979606A335;
	Mon, 23 Nov 2026 12:48:56 +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=nilGTLgC
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=1795438135;
	b=EZ5jreZFIdqoJCiZ4WAImpeQWDrA3BKTqzGnjCCfyfqlhEoM7PlXJYXPZbJsJCIfjACD
	 59CNy84NGabvDEydYq7sKN7dmPwt72qQuRy7+Rvb9OstdQ2ENc0N2kEGI+odX6IqmU/Ij
	 hM6fwN8jgiNYyGKeJISi7lp59MbwiqhzlGP/CZflrKa/8jZ7nCD1X8KInjT4/TqjRmjEW
	 ndyrQhkNO05qwI4pLcLXmdu+7DukHi66Jv4WBvSXr3wDSkC/QWvNzPOuVuqYG0aaTMIVG
	 xfXV+1YRdY/8IuoyxBBWsae04/G7FKluIRfsZRGQcIdODwK/9FFobLzgH/ZAZHCNDBg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795438135;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=yI2Wo78/lAboL4lqhYNXgiMMUATpxcgIbU7d5ySHTsM=;
	b=tDzsCzKyR2euU20ManvBRvUjYmTnwdkszjLGHqcw6JtHjNNK7FyHVfOY1lncakyEwFWh
	 dv6uudFkhjdIKqNkUY2/UJKI2L6dAQ+qCW/tebMGCrMYnBYfujKebAuC0jg9OOmJhZTDh
	 BRS3o5c+977Cb3wP8wVRACN30DhK8f+EXayeMFd8MuVigDURw7g41pWXYnXI1aOJSrVcB
	 OiZsZIBBa0nmHFnkExpfWbkzIPr1bG2sHaKcyxiH8Lq6p5rlItth/ViV/flpqq9U4gu6J
	 wRwxLC62JYJKFhAnlqoL8OvphHJ8RgeuhjNV+TnHySehkmezTKW5UJ+5K+rIobSJ8uw==
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=nilGTLgC;
	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 AEBA6606A31A;
	Mon, 23 Nov 2026 12:48:55 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80C4D1F000D0;
	Mon, 23 Nov 2026 12:48:54 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795438135;
	bh=yI2Wo78/lAboL4lqhYNXgiMMUATpxcgIbU7d5ySHTsM=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=nilGTLgC5K9CC6eh63Q0pR7rGHQfz6Pjl3M2IuE6LL6EKvJStnDSSHvavsd5JP3ip
	 AqEu1ZMc2cbdH34sZnguZeHE9WfwW0jJvWHLv20K/2w7BigtbyoFbcdYMpBEebNscM
	 wwAtuLm5mBFjX39eX4myW4HlkRrLqQk1Zwva8ZU8zl4geMZ7ocf83d1IjgAtxo+Uz0
	 ZylFfG8IdUXhShpMDqangaE49FOVy8YxlNOhxnNgjU01NznZ9x2btjqQPugeYkhQVO
	 9Cns9kWwFkfX9PfSOl4waywvScWLXVke/iWMbe3221BzJdjMOzMhyAptTU7goZ3Bsd
	 Ae+aixnb7+E4w==
X-Cc: jhs@mojatatu.com, jiri@resnulli.us, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org
X-In-Reply-To: <20261122-b4-02-act-ife-rtnl-uaf-v2-102eba468698-v2-1-67c413c45928@pm.me>
X-sashiko-severity: High
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