Article View: linux.kernel.netdev
Article #15644Re: [PATCH net v2] team: validate the length of U32 and S32 option data
From: Hangbin Liu
Date: Fri, 13 Nov 2026 07:10
Date: Fri, 13 Nov 2026 07:10
72 lines
11299 bytes
11299 bytes
On Thu, Nov 12, 2026 at 05:00:30PM +0800, Wenbo Sun wrote:
> 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;
> + }
This part should be
Fixes: 69821638b274 ("team: add signed 32-bit team option type")
Thanks
Hangbin
Technical Details
Message-ID:
<ava3_g_zsVdAjn93@fedora>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362469-linux-kernel-netdev=dewy.ruReferences:
<20261112090030.172342-1-sunwenbo@cmss.chinamobile.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362469-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] team: validate the length of U32 and S32 option data Date: Fri, 13 Nov 2026 15:10:54 +0800 Organization: Usenet Network Message-ID: <ava3_g_zsVdAjn93@fedora> References: <20261112090030.172342-1-sunwenbo@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1299032"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:HqD+/+WaCB06VG4znBMRanOf17Q= sha256:SGnXyz5WhjXR91nfjMD3hFfz17y2grdHYNM0DOADYFI= sha1:bTDTwb2aXTO/0RcHUKWPBGAObyo= sha256:f+0G42bGx8aoLXKtZAZwoWNoR0/3ndjuHFjcas8x7wY= Content-Disposition: inline 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 6FA7F1144CC; Fri, 13 Nov 2026 11:42:28 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 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, 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=pass (1024-bit key) header.d=linux.dev 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 3DMUWxbbYkgE; Fri, 13 Nov 2026 11:42:24 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-362469-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id C879D11446A; Fri, 13 Nov 2026 11:42:14 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id AC9FA1E3A32; Fri, 13 Nov 2026 07:11:14 +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=1794553870; b=sBEoakq9C9hydHwrJJ+YzMfH9d6eVv6wqznc8wv2qnK5tSxKhbmSkALhcHSKLDuiAwMC fZwjwRc7wsyuZJswBxURMiOELPL7/K9SGSNJd70VPOpApv9AcEvNofaHepJtyAL0Gb0zt iHyR5IhlYV53to4W1xdvNlUI3iJvXcZtR8kuNq8aAs2Ri8Medur2sxfCC8acyzucc9Z2v hWAzxSL1bfU9joHB/1Q2HG7+iOp3mZgb2tec57m7Yuu3XMQorJc1ZSIcFwvVAChUwBYCS u88lcYeS7/ktuDuwCJyhj1IEJW+dKtNL/yxSwzeqvNDFShdDgIKNqaI++7wITUqZUEw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794553870; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=IJWs4zNE+gIaPoa05xg+qHkXlF1ISQhiWNboOXFLzhc=; b=Al2xDJvqAJP639HKLJQoAZPzcvai3cYGBbADfwglVf99M5IHmPeP7GASHrNToa4goY7A qjWN03Gr8rSvFDzciJ+910Pk4jxAidTgb0dfZ53rBlNW9/57D4bZhG0QSZahEaKqMpnxR ZB76jZim4gly376IH7B3gUWYEnGqAHOJY0kpul59k2dYPsrixtmfGD+phJow9X+slgA4f sUyukRqCGn1uQeBMmn7bU8mGpXZgRt+I0ovvGAepdBAoHULtZyJqOMyiXFCPIBWdm0xk0 nzrtHHbC8lkV42i7PoBqR3kXHCvfQuPnI/QBzKMxk+tWk2z+YvEZs2kg26jMFMv33fA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=CgLSTeyw; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; 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 07871606A337; Fri, 13 Nov 2026 07:11:10 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=CgLSTeyw X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.92 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794553869; b=wx21qJwIWKCuqWiHmLaQfAG8PxFBTc/Eqat6KyGItSxRneFTiq/pus2mYT7QYJWbZu0A F+iYijB5NJPz290ffcBYKxJf8OQCa70T93H9A2QPPFECtTBCfnlcS0TmxW1LuANAHLMaX qbsS/T/+2Ieqdu/dkPX9PikObCOiAPcHGW5KpEyeTGmzFq/Jd/cWKZsRvpApsYKSWfI42 WrKb2h1Vq5TgXNvz9IZ1+d+Lm3sufRpePAqBJN4l+fu4WvP0Txn5R1AKG2RX7sqkqMTlY 7Ezgs7m+Rlb8K9ADCjhMWtxukMGXNlKQpYr//wCFg2jBrFYVKJKiFer232t0iqDWKDA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794553869; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=IJWs4zNE+gIaPoa05xg+qHkXlF1ISQhiWNboOXFLzhc=; b=LiBxnLWdl5X+V5223xWSBBIxkYys2kWOfWzqLez1FJrlXWvNOH5edy6UpOQz9zHOTlSo vd4ZSGFcgqOKC5/QeotQefysp1oZW/lELkX9ytqXWVkP0ryyZoqk1wWyIva2t+XS09wAD 0OYoqO3dSDy/2pAhLrLsc5eHs8neHTJE+C4hhyhCzSo64G4aYsMx6ym6ARuBMs+swDenF rGHRIF7OyWO3Gytj1yrnr8kzkca2dQoRDrkGzZ3jDvhrPOi4E/YWAqOGfyMRMu1jiAlDv kUc8WuMTAPEsiiSkZGvV4k1cK/DDE8uuHN+v7sZYbusYXlu4BxxINgU75V39dMex7Iw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=CgLSTeyw; arc=none smtp.remote-ip=95.215.58.92 X-Received: from mta1.migadu.com (out-92.mta1.migadu.com [95.215.58.92]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D88D606A323 for <netdev@vger.kernel.org>; Fri, 13 Nov 2026 07:11:08 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6D88D606A323 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=HvD4JIhX9JMIJD9FDvhvLpV8go5wxlXlCHjEMqjep6A=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794553866; v=1; x=1795158666; b=CgLSTeywh5Ab76k4izWLBgQt+Afg18seRiEqC7lbW2t9NqgZjXIGu+u9pAKnIXWzjcG1HMuX a5r0n/1ea6raM92cULa4ySd18U+ls4Oc4NBOux2yYlHjrH8FE4a/hyI5BPd0T4hSBlGeAWgTHEZ DrejQYbHdD5j9uoXOO0gTuaU= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta10.migadu.com with ESMTPS id 04b16ff434ed104c; Fri, 13 Nov 2026 07:11:06 +0000 X-Mizu-Trace-ID: 04b16ff434ed104c X-Migadu-Flow: FLOW_OUT X-Cc: Jiri Pirko <jiri@resnulli.us>, Andrew Lunn <andrew+netdev@lunn.ch>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, 1342116488@qq.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-In-Reply-To: <20261112090030.172342-1-sunwenbo@cmss.chinamobile.com>