Article View: linux.kernel.netdev
Article #12028[PATCH net-next 1/3] net/sched: act_gact: size TCA_GACT_PROB unconditionally
From: Linkui Xiao
Date: Fri, 06 Nov 2026 06:41
Date: Fri, 06 Nov 2026 06:41
73 lines
11757 bytes
11757 bytes
From: Linkui Xiao <xiaolinkui@kylinos.cn>
tcf_gact_get_fill_size() reads tcfg_ptype with neither tcfg_lock nor
READ_ONCE(), and budgets TCA_GACT_PROB only when that read happens to be
non-zero. Both halves are wrong.
The bare read is a data race. tcf_gact_init() writes tcfg_ptype under
spin_lock_bh(&gact->tcf_lock) when an action is replaced,
tcf_gact_dump() re-reads it under the same lock, and tcf_gact_act()
reads it with READ_ONCE(). get_fill_size() is the only accessor of the
field with neither. act_bpf hit the same problem and solved it by
taking tcf_lock in tcf_bpf_get_fill_size(), with a comment explaining
why.
The conditional budget breaks the rule that commit 4ba61bfd4998
("net/sched: add get_fill_size() to the five actions that lack one")
spells out: "Size every optional attribute
unconditionally: reading the current flags to size it conditionally
would race a concurrent replace, which can flip the attributes between
sizing and dumping." A replace that turns tcfg_ptype from zero into
non-zero between the two calls leaves tcf_gact_dump() writing a
TCA_GACT_PROB attribute -- nla_total_size(sizeof(struct tc_gact_p)) ==
12 bytes -- that was never budgeted.
Size TCA_GACT_PROB unconditionally. The budget becomes an upper bound
again and the bare read goes away, so unlike act_bpf this needs no lock.
Nothing overflows today, so this is locking hygiene plus conformance to
the rule above rather than a live bug. All four consumers of the value
-- tcf_get_notify(), tcf_del_notify_msg(), tcf_add_notify_msg() and
tcf_reoffload_del_notify_msg() -- allocate at least
max(attr_size, NLMSG_GOODSIZE), and the delete and add paths add
tcf_action_warn_attr_size(extack) on top. NLMSG_GOODSIZE is
SKB_WITH_OVERHEAD(PAGE_SIZE), so a batch has to carry enough actions for
attr_size to grow past roughly 3.7 KiB before a 12-byte shortfall
matters -- which is the failure mode that commit 8e2efb3f45a5
("net/sched: add get_fill_size callbacks for actions missing them")
fixed for other actions. A replace cannot interleave between sizing and
dumping either: RTM_NEWACTION, RTM_DELACTION and RTM_GETACTION all take
rtnl, and the classifier path, which can run without rtnl, computes
attr_size in tcf_exts_validate_ex() and discards it.
Tested by building with CONFIG_GACT_PROB=y so that the code being
changed is actually compiled; net/sched builds with W=1 and no new
warnings. Patch 3 adds TDC cases for the gact dump and get paths.
Fixes: 9c5c9c573700 ("net sched actions: implement get_fill_size routine in act_gact")
Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
---
net/sched/act_gact.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c
index 565860cccba6..ec9a65dfc442 100644
--- a/net/sched/act_gact.c
+++ b/net/sched/act_gact.c
@@ -233,9 +233,10 @@ static size_t tcf_gact_get_fill_size(const struct tc_action *act)
size_t sz = nla_total_size(sizeof(struct tc_gact)); /* TCA_GACT_PARMS */
#ifdef CONFIG_GACT_PROB
- if (to_gact(act)->tcfg_ptype)
- /* TCA_GACT_PROB */
- sz += nla_total_size(sizeof(struct tc_gact_p));
+ /* tcfg_ptype may be set by a concurrent replace after this budget has
+ * been computed, so account for TCA_GACT_PROB unconditionally.
+ */
+ sz += nla_total_size(sizeof(struct tc_gact_p));
#endif
return sz;
--
2.25.1
Technical Details
Message-ID:
<20261106064114.3592670-2-xiaolinkui@126.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357787-linux-kernel-netdev=dewy.ruReferences:
<20261106064114.3592670-1-xiaolinkui@126.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-357787-linux-kernel-netdev=dewy.ru From: xiaolinkui@126.com (Linkui Xiao) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next 1/3] net/sched: act_gact: size TCA_GACT_PROB unconditionally Date: Fri, 6 Nov 2026 14:41:12 +0800 Organization: Usenet Network Message-ID: <20261106064114.3592670-2-xiaolinkui@126.com> References: <20261106064114.3592670-1-xiaolinkui@126.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3812344"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:8GoJpJh3HL/Pkt0UBcC1gyzNzEo= sha256:vtZUZJVjc02MYqwuc0H+TCgaiCgl3h6hP88TUaljXMg= sha1:1amWbkE4ni2NPp72Xdgb9FMUjRU= sha256:UgzmYZMkJiqudM11IuoZjp9T4BdvjRhKi1kcFjuQ6Wc= 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 EBF8F113181; Fri, 6 Nov 2026 09:45:31 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.048 X-Spam-Status: No, score=-3.048 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, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, 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, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=126.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 HrT6c9QU4hrh; Fri, 6 Nov 2026 09:45:29 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-357787-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=126.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id A7F1F11309C; Fri, 6 Nov 2026 09:45:20 +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 1786A30414; Fri, 6 Nov 2026 06:42:16 +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=1793947335; b=X1EtrdsAeWr4/YqfcS46Xo7Md8SShHguBLeH0mX9LbTrC8xDGS04Xcag5mHwwsgHhSMV FEPVLKb5KokqInQQlgChM/FaTiodYZ188R7JSi+k7+u5aA0sQhBK1JJYLmmcxbn1NC56G 39Amplln5LLgK6YNiAnewKe/wQXW9crMQhG5txw4nSbZSdgKpY0dOZQW/1lmf170qS4kW 5mt32TuI0Lp53I5DwZvEjJyGQGbHSo1HzGM8Owil/jLyZRV8LVCQZ0OIdD8xc8R4s68wb /H1zoRfDZiQqv3KyIoJbH72qkr0FYXWGoRoKLjAzbabJ0CbFbHl3yGL7xDOrgMmaX5A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793947335; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: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:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=KL5V+v3cUK42avBygg/NokDd0cEzHSdupAtDovHJxz0=; b=kcv4FzdP86m23yuWpj+1cmOoIFbC/eIeM4sZtkXo6IxvNyI7ZMldya+KQun8weE8sool Ci0p5VE3PAA2pIG1QHS0wNwVOKibgbRhDIxpeUrGhwpSHQIQghcLRyURHRPdzKYYBloFX mPJ4t38rcVPjTvKVJkeCPk1n2kS/mKMpi1mn7z9Vtc6Qn7spDWZexbMJS5l/npdFt9LmZ s3AEoT1lEjjRDXs4sRXes/kqKvPIpbj1l8VrUDOpPreB1mSYqlDEqNo88ZUhdwQ8JOcUy 3WbWVAsRfF6TMkWY45XELt5LOVmJbZvIdua8scyDaZQLzxrYsmp0x3MnTzu9EI05esQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=fGhQ7jXb; dmarc=pass header.from=126.com; spf=pass smtp.mailfrom=126.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 A1076606D803; Fri, 6 Nov 2026 06:42:15 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=fGhQ7jXb X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.8 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793947329; b=Cmz2L+UriXqdw5K4hiXgAF3pwcna0O9O3WjDKueFY75Lh5/BgwF9qtwq5rrZ9LBtD1Tj OO7/BrnMsYl3BtoSmOaWyCyZWk9qECS4H3uuCdhaP0gVHrDBsB2AiXMyO2hZk87GwEhVd Y81UjxFqXmW2N4++74SeCMZNgw/yrpl2kU4GG2L03IfZa2Ber5B1E8daMp/xFayRstmmN Ld5qXSTP8CkF6MA4fcVP0BDi8UC1hX9cDFFcsQmyI2XreHqb9AsR/wkaSg+HzOfpsM2Eg rIpqErnaJn4U6iRrUL3lAYNPpiGbUlXb0jrPNtpCw7gw1eVMAZ2HEomYGcpI8i0TScQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793947329; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=KL5V+v3cUK42avBygg/NokDd0cEzHSdupAtDovHJxz0=; b=h3OvxF4zrjAUmUUQVwXNSZcm0ZdbpvVob0JXcWT24FXbO/91Lj6h3FZDm4Y9IZ8Ij9+U VDX76/gy454ff/u2+jXx0N+crcmAsszdL+md/v4JZk1mo9OS1zWS5oEbCX5CmE4Wf8AYI CUeUr/Q5tMdHkoijMF8yFrNFMWCZpPERv4J9/64CW0fBTfmqOUHszQSponybdYnZqUKpu Xmd39lTRg3HgAkVclU0vDQDfHCOJwhXzvww62nWsKt8ZMJuadSphxZRU3HPmIk/Jyn14I ukDdvib8cIg3Fbq7Tv5qoykOVDX92vnw+yoEr3slwoPJWuVun8u8d7FTvMESrYvWaOA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=fGhQ7jXb; arc=none smtp.remote-ip=220.197.31.8 X-Received: from m16.mail.126.com (m16.mail.126.com [220.197.31.8]) (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.subspace.kernel.org (Postfix) with ESMTPS id 03640606A335; Fri, 6 Nov 2026 06:42:07 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 03640606A335 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=KL 5V+v3cUK42avBygg/NokDd0cEzHSdupAtDovHJxz0=; b=fGhQ7jXbQHVw0UGkPC ssOlfF5LBueH95TOQYsjOaGHMMpbXCISFsP/+Z7tqQCM0fgbDDDo8ZpQOhnC8reB w/LlG8i5BSQAXfGBUQk0nDJGO/5BJWBoGsbEyOVk539RR2Vjy2g5c/9srhtCG2XY TCWIGy+qmQE2+mYYgUPSnrnsw= X-Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g0-4 (Coremail) with SMTP id _____wDnR+uMdu1qZ7kzCw--.3170S3; Fri, 06 Nov 2026 14:41:19 +0800 (CST) X-Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Linkui Xiao <xiaolinkui@kylinos.cn> X-Mailer: git-send-email 2.25.1 X-In-Reply-To: <20261106064114.3592670-1-xiaolinkui@126.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-CM-TRANSID: _____wDnR+uMdu1qZ7kzCw--.3170S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxWFWkZFWfGrWDWFWrXrWUJwb_yoW5tFWkpF Z8WayDCr1ktry7Xw48uw4xZa4S93s5CF4UWryakw1Fkr4kWwnxtFyrK3y3Cry7Grs3G3s5 Zr1qqr17GF9ruaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U9AwsUUUUU= X-CM-SenderInfo: p0ld0z5lqn3xa6rslhhfrp/xtbBqA-WrWrtdo924QAA31