Article View: linux.kernel.netdev
Article #14974[PATCH net v2] team: validate the length of U32 and S32 option data
From: Wenbo Sun
Date: Thu, 12 Nov 2026 09:00
Date: Thu, 12 Nov 2026 09:00
69 lines
11189 bytes
11189 bytes
In team_nl_options_set_doit(), the policy for TEAM_ATTR_OPTION_DATA in
team_attr_option_nl_policy is NLA_BINARY because the payload layout
varies with the option type.
For TEAM_OPTION_TYPE_U32 and TEAM_OPTION_TYPE_S32, the payload is
read directly with nla_get_u32(attr_data) and nla_get_s32(attr_data)
without checking its attribute length. When userspace supplies a
truncated attribute (0 to 3 bytes), nla_get_u32() or nla_get_s32()
performs an out-of-bounds read past the attribute buffer. Conversely,
oversized payloads (> 4 bytes) would also have trailing bytes
silently ignored instead of being rejected as invalid input.
Validate that nla_len(attr_data) equals sizeof(u32) or sizeof(s32)
for TEAM_OPTION_TYPE_U32 and TEAM_OPTION_TYPE_S32 respectively, and
return -EINVAL otherwise, consistent with how NLA_U32/NLA_S32
attributes are validated and similar to commit 5bef3ac184b5 ("team:
better TEAM_OPTION_TYPE_STRING validation").
This issue was identified with the assistance of an LLM-based code
review of Netlink option handlers in the team driver, confirmed by
sending malformed U32 (notify_peers_count) and S32 (priority) option
attributes on a UML kernel, and verified after the patch that
invalid lengths (0..3, 5, and 8 bytes) are rejected with -EINVAL while
valid 4-byte options still work as expected.
Built with W=1 on UML, x86_64 allmodconfig, and x86_64 allyesconfig with
zero new warnings or errors.
Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
---
Changes in v2:
- Check exact length (!= sizeof(u32) / != sizeof(s32)) instead of
only rejecting truncated payloads (<), as suggested by Hangbin Liu.
- Extended the UML test to also cover oversized option payloads.
drivers/net/team/team_core.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
index 957cc7885d2f..8fa05c489b99 100644
--- a/drivers/net/team/team_core.c
+++ b/drivers/net/team/team_core.c
@@ -2833,6 +2833,10 @@ int team_nl_options_set_doit(struct sk_buff *skb, struct genl_info *info)
ctx.info = opt_inst_info;
switch (opt_type) {
case TEAM_OPTION_TYPE_U32:
+ if (nla_len(attr_data) != sizeof(u32)) {
+ err = -EINVAL;
+ goto team_put;
+ }
ctx.data.u32_val = nla_get_u32(attr_data);
break;
case TEAM_OPTION_TYPE_STRING:
@@ -2852,6 +2856,10 @@ int team_nl_options_set_doit(struct sk_buff *skb, struct genl_info *info)
ctx.data.bool_val = attr_data ? true : false;
break;
case TEAM_OPTION_TYPE_S32:
+ if (nla_len(attr_data) != sizeof(s32)) {
+ err = -EINVAL;
+ goto team_put;
+ }
ctx.data.s32_val = nla_get_s32(attr_data);
break;
default:
--
2.33.0
Technical Details
Message-ID:
<20261112090030.172342-1-sunwenbo@cmss.chinamobile.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361623-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361623-linux-kernel-netdev=dewy.ru From: sunwenbo@cmss.chinamobile.com (Wenbo Sun) Newsgroups: linux.kernel.netdev Subject: [PATCH net v2] team: validate the length of U32 and S32 option data Date: Thu, 12 Nov 2026 17:00:30 +0800 Organization: Usenet Network Message-ID: <20261112090030.172342-1-sunwenbo@cmss.chinamobile.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1047322"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:+LXeDjcn/8QeDZe5VDGNYkJS83Y= sha256:1T8hzWOo+zr2Zy0zrcu3zOXlwx+twLn0wEmyQycbH5k= sha1:p0RitulZdIqOKad6Vj+FxwGsAvg= sha256:Px/Jk76EHpd4+22a7STInDYspGBrRYa+We+QldARxSE= 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 3CA50114166; Thu, 12 Nov 2026 12:12:57 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.751 X-Spam-Status: No, score=-2.751 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=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] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key) reason="fail (body has been altered)" header.d=cmss.chinamobile.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 mGS09U0Ue7_S; Thu, 12 Nov 2026 12:12:52 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-361623-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 99D8D11415D; Thu, 12 Nov 2026 12:12:42 +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 3344BC61EA; Thu, 12 Nov 2026 09:01:01 +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=1794474057; b=23tRF0WkQcvd0r3sjYvRPpQNsburof2aucGnJNmTV7GpLyimQaxS9Iz+VXBqgMUI511q G68ZRWYPmSGOiy8oM6MSAgAmxcV+GjHG9fd11rzrdCGbpu20UHyDqamOM1umVmVGRMXmF YQ8ACLmh/uu8/a1SCV8N+i6BvBaBI5SlJA79aHwmP6mzEAOrC+qetRegEkm3fA+CGYRSb yrT1rbCagjTOCQwGNKWXaHULuj/nhWcOpgL8Xnlv4pR1HIUEBY2kr0hViJv+qUd/BZeMF SErisRmeI2MByRPdGjrAl7kxSW7EuXB6epctN3kkt2rG1iiJjZHPh0zcgTcrrp/Jp3g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794474057; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo: X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG: Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-Id:X-Mailer: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=DP15FYKEHXO6xoDhi4j3CgcS1prpD18B+3vZ34NHmTc=; b=J04n0xpOlIHHSJwzOqMlXlky01bJhGL5bmKD5b/6wrvPYdw7zy4MjWnoj4deE3gg5IMv t/LIoYaTotQ7Pt4prtZk7MmQW6VGwG+RZ0hs6GT7hmrMDzLgbWM17DTOl6AQalyKrFtjm 6O/PIyR2tx7TQtK1mq+896ld1oB8l/8peDyJAMOn9tcGOqIqc1Aia7/Fsy5FCnFtztnhV iOLv2U+KjMGNjcRsrEGosT7P8ewMOhTN1tn6N7+8eRCJqKRxELvgUr44jhQPenhhuguqr e3c0znoHA0lA4vVIBbTSVyZd0UBqVQ+yIYLrcq/o5qG+EiClw3aG1AOxCvGI8lJGkLw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=tB3cVqC9; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.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 1D1BA606A337; Thu, 12 Nov 2026 09:00:57 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=tB3cVqC9 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.137 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794474056; b=HaA5/68Ca1XmV4qZR8fJiXE+0V8s5787BNIzl5Yx10DR9/ZHL8Vm1Mi8L/MCDYLme1ZL PdgmQyjw30uFZVhxd78/rL0xquHUbMDTGZkHFrPPHqDDWezwkwZhGM3Ye5G0gBGff/Xvc VNvjat16FRlmF2mqGBkhewgne0MHKJTtbGGkLP3N4ElH3if1RJnjO0LtMIQnt4Ko4qPlq YIMV67fqJ6Z4sr2kdDCJAJ6mwhsKhEDXZ7NKZn7HNdxs2OtNY0d1e8NU5Wj/W10rXF6OV A8ejQjhzdBjNT/7T8k4z0Thlyb/lRrmpywM6GarKQv35ibPOdfDegdUXAncB/PuAGLQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794474056; h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received: X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From: To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=DP15FYKEHXO6xoDhi4j3CgcS1prpD18B+3vZ34NHmTc=; b=aPeOTTXTBsGAklXGVuVCx8BFJiTbf6Npo7Ev357rqqOr6yk/yLLFlOezdhmpz5VGBLgF x8dUb/g5Ay3Anh5ImsGwqrWpPjH5AfE5dpbxFlMMsiXH38jIBPoUBxZhc8Zydzw2REFJE gyt+AwG0hNFbFMejpP3Hj7nJX3KL2oh3uy96imqZ3zkUUZnd3WlCK9vNOGVun1+smWsVj KEuqy4lFx+sNvImvZ6CXVex3ibt7yM4rJHJn10JXQZatzGxIYiR2cllt0B7L81vIKFTTC N1CQP4sGLP5moaSdxXuH7vq4YhNaCdKlzebuA8h/G/i6HSAVytiGWZtODKTe9xV4efA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=tB3cVqC9; arc=none smtp.remote-ip=111.22.67.137 X-Received: from cmccmta4.chinamobile.com (cmccmta4.chinamobile.com [111.22.67.137]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9996D606A31C; Thu, 12 Nov 2026 09:00:54 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9996D606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmss.chinamobile.com; s=default; l=0; h=from:subject:message-id:to:cc:mime-version; bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=; b=tB3cVqC9ntwAcc0M/0QQfzsjhVr7ZZAICDPR44mCA9SC6MF4eWYA2+g4ipgOfmOwUc2AO5UbhuNri tn+GwT+cSBxFOypU4H+CHUqZNy02/VrIYbZORFvD+b5SPuffZvcxPKxTfHDqMOVsJurug/dl+B55tf nLfFR5bNn/tFfcFg= X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87]) by rmmx-syy-dmz-app04-12004 (RichMail) with SMTP id 2ee46af58043ad8-80ab4; Thu, 12 Nov 2026 17:00:51 +0800 (CST) X-RM-TRANSID: 2ee46af58043ad8-80ab4 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from localhost.net (unknown[112.23.105.204]) by rmsmtp-syy-appsvr04-12004 (RichMail) with SMTP id 2ee46af58041f7d-fa36d; Thu, 12 Nov 2026 17:00:51 +0800 (CST) X-RM-TRANSID: 2ee46af58041f7d-fa36d X-Cc: Hangbin Liu <hangbin.liu@linux.dev>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sunwenbo@cmss.chinamobile.com, 1342116488@qq.com X-Mailer: git-send-email 2.33.0 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