Article View: linux.kernel.netdev
Article #14444[PATCH net] team: validate the length of U32 and S32 option data
From: Wenbo Sun
Date: Wed, 11 Nov 2026 08:59
Date: Wed, 11 Nov 2026 08:59
64 lines
10900 bytes
10900 bytes
In team_nl_options_set_doit(), TEAM_ATTR_OPTION_DATA attribute policy is
NLA_BINARY in team_attr_option_nl_policy because the option data format
depends on the option type.
When setting an option of type TEAM_OPTION_TYPE_U32 or
TEAM_OPTION_TYPE_S32, ctx.data.u32_val or ctx.data.s32_val is retrieved via
nla_get_u32(attr_data) or nla_get_s32(attr_data) without validating that
the attribute payload is at least sizeof(u32) or sizeof(s32). If userspace
supplies truncated option data (e.g. 0 to 3 bytes), nla_get_u32() or
nla_get_s32() will perform an out-of-bounds read past the attribute data
buffer.
This issue was identified during a code audit of Netlink option handlers
in the team driver. The bug was confirmed and reproduced on a UML kernel:
passing truncated option data for notify_peers_count (U32) or priority
(S32) succeeded on an unpatched kernel instead of failing validation.
Add explicit length checks for TEAM_OPTION_TYPE_U32 and
TEAM_OPTION_TYPE_S32 in team_nl_options_set_doit() to reject truncated
attributes with -EINVAL, similar to commit 5bef3ac184b5 ("team: better
TEAM_OPTION_TYPE_STRING validation").
Tested:
- In UML, verified that sending truncated U32 and S32 option data (0 to 3
bytes) is rejected with -EINVAL on a patched kernel, while valid U32 and
S32 option settings succeed.
- 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>
---
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..617f13e1620c 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:
<20261111085924.360720-1-sunwenbo@cmss.chinamobile.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360935-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360935-linux-kernel-netdev=dewy.ru From: sunwenbo@cmss.chinamobile.com (Wenbo Sun) Newsgroups: linux.kernel.netdev Subject: [PATCH net] team: validate the length of U32 and S32 option data Date: Wed, 11 Nov 2026 16:59:24 +0800 Organization: Usenet Network Message-ID: <20261111085924.360720-1-sunwenbo@cmss.chinamobile.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="816028"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:yB+WEAQmKSoOgKjwa0LGdh6lQns= sha256:TK3F8Y5PHOm2xUhBVET2LnNvy1m55rgASHL4gCKu5XA= sha1:dr1Enor0UzSTajbabnuetlNmRNY= sha256:J31odcXN2miD2zB4LjLxBuT/YmUj/WOQ87MC7RwReow= 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 EBB4A113E6C; Wed, 11 Nov 2026 12:06:23 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.75 X-Spam-Status: No, score=-2.75 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, URIBL_BLOCKED=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 tEetb58fDMsv; Wed, 11 Nov 2026 12:06:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-360935-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 430E1113E6A; Wed, 11 Nov 2026 12:06:08 +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 6AAA6A694D; Wed, 11 Nov 2026 09:00:05 +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=1794387591; b=UKyKcu1pnd9rWxLzr+dMomuDNK5tOOIUJbfkq1reivrU8CFzmsIcieLoF6WCOh1CiJ85 Wjjy0HuLNkWsKp15KHMmv3twCrGm2ebuwyj2MJUNkolt7HHTkxT3ZNeKCZ7CuDxsTo/Pt sVtYEMsUEnl9/KcZt2Cn6bNCAAotEwov40nMf92NpoUqOtx9nclYXOi7G9BH7+9urVg2W 0GajWtw+KuGr+wAYRaGdhj00c5R/SV+zpyrSOKePK8WHORIZ+7FNMuVM9ZbTKWYAq94b/ nkC6XTj1rSsTCPoEQeShEz7YgnTF7928ggYE5+PgQcHNafPuebPmaoPOJ9nE+lP0tbQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794387591; 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=8reTPqAv/HMHrkP9uAWId+/q6jL4L2PpJVCKg3Q/rmA=; b=oLuyRy5aYz1gL484GqX5+hD44lkIa5N0f1ZNH8Wm8UZ69O4eLJNnBuqMTejLmlnu0MxA F9nN72K4AJ9qDKkvWzAPW3AlNRETn0ELIbp3CikKgtbBRzBkBN0Bt3aO/3aO78xFaWfvz 6uSb6alwfrklzFcsjXGfGQ6857nooP3z+EAITlNArnDc3U5TVAsk2BXIeehV0ibwU3lzc MPqRfvHo1Lho1nl8dVGKVQGiFt7YXIBtK2wfl4DOC676WwsF71Hh/AFEYcedANGm54hdx HM6QUJF3ODKmQwPsGSoAwrp2ACx2hD7/4Wa/OcEv0EECcWoQgD8u7vL1xLifBHCMYGA== 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=RshZOywD; 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 796EB606A321; Wed, 11 Nov 2026 08:59:51 +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=RshZOywD X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.139 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794387585; b=AgmODHfAn4qBREWH8VzY6sGx224aPg+y/Re+yhLZvZ5WHZ9bpuquBbtamBfzOKMo1z32 D7iuKn+OGm5fWD6StlWDNhT4ET6G8ngtbU3lYHBLXCUaVOmufLxjwoz/HB3V/dd6eTE1Z 9rFDNQaON6aZC4sY+B6PV68GP1+KH4qWIGg4K9halmhfdYmmpYvbq+QHzovJisE9EX2/3 /ZercDIb/RYH+eQfoMjhzXyys+FP+TeiM9c5r29vOf865hTj12si8rVpUrqEqNuLY/Gil DPbX4o/XgQS3PO59YA0rIPgO3w4/qpe7YkAra9ymurPx1UjIRifUQfy9eW+OL+XBSIA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794387585; 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=8reTPqAv/HMHrkP9uAWId+/q6jL4L2PpJVCKg3Q/rmA=; b=IdCiEnHX7d60wcLl6vnpzwzjazabD582Boh4cnSARMaWdJXe559u1VpYzHnznM4U5xPJ LmFWy3tolnQ7z4yJ9JOc64QNJxsgTrunTsFMdtAVTjW5+bMWYN0GT94Y10IVZ3fuHBhOy D08126d9FaJvVtH+fd4u91Ftx/t/rJHRCEAMcbsKI0NayOFdiJZRSQZO1v3PzeF5uwGJp EG4iAkK+6oU7uLG8pTS+jEXFPoxaocCtTQqoUh/4XKj2jNMSkoo4nywXlbomiUzQmRXOd LTwAP/DUuuZhLcmJeGJkySaGlhlUget5HIY1EVLOscGhBpeOO7HNUiR+D9e0MO2vzoA== 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=RshZOywD; arc=none smtp.remote-ip=111.22.67.139 X-Received: from cmccmta6.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2E1D606A326; Wed, 11 Nov 2026 08:59:43 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D2E1D606A326 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=RshZOywDJBzjLlLST0gPvThT/lg+DhF2ZAZA54eo0c8iQZ4xUkMZF7Clii+j7h8kc8i5ofEUsDZ/H PJqHePAmoMXmUnlK9xVpSrrIoS3y9K6VatteS1tRLizDG3ePfMyJn7IqXTgM+5oXHBndVD78JKln7H YGVMPPi+x6b20c7s= 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-app01-12001 (RichMail) with SMTP id 2ee16af42e7ba71-b2f41; Wed, 11 Nov 2026 16:59:42 +0800 (CST) X-RM-TRANSID: 2ee16af42e7ba71-b2f41 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from localhost.net (unknown[223.64.115.200]) by rmsmtp-syy-appsvr10-12010 (RichMail) with SMTP id 2eea6af42e7dc68-d5e99; Wed, 11 Nov 2026 16:59:42 +0800 (CST) X-RM-TRANSID: 2eea6af42e7dc68-d5e99 X-Cc: 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