🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14811

Re: [PATCH net] team: validate the length of U32 and S32 option data

#14811
From: Hangbin Liu
Date: Thu, 12 Nov 2026 01:22
73 lines
11189 bytes
Hi Wenbo,
On Wed, Nov 11, 2026 at 04:59:24PM +0800, Wenbo Sun wrote:
> 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:

What if the data size larger than s32/u32? Should we check it with

  if (nla_len(attr_data) != sizeof(s32))

?

Thanks
Hangbin
Technical Details
Message-ID: <avUUw4deZxrmGJO1@fedora>
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-361421-linux-kernel-netdev=dewy.ru
References: <20261111085924.360720-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!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361421-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] team: validate the length of U32 and S32 option data
Date: Thu, 12 Nov 2026 09:22:11 +0800
Organization: Usenet Network
Message-ID: <avUUw4deZxrmGJO1@fedora>
References: <20261111085924.360720-1-sunwenbo@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="981145"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WsPJc5Z/PpURBloDFTGa4E3uDRY= sha256:NIbwqh9e4jUCC+Nga/2TWgQboALpQtgK9QizNu6L4ZI=
	sha1:cJCOruU2xTDs1bS51/sixFRszjw= sha256:8yfi/eTc7VaI1qSGYDvi/lqKxzXBuGzx8i1KQogZTag=
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 107D51140A9; Thu, 12 Nov 2026 04:26:29 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 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] 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 YHMHcAbGe1XJ;
	Thu, 12 Nov 2026 04:26:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-361421-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id B40CA1138A7; Thu, 12 Nov 2026 04:26:12 +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 DF3CD3C628; Thu, 12 Nov 2026 01:22:27 +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=1794446545;
	b=utbYQYL8AWJbsLwYhBXjlJSrjm2ghIEYoJGPCEm+i4RjxZos4eKYyJFiSmXiq+daYsH1
	 XdmFfguUSsHYSAZFFh8FwpxhWeaUq+xUobbrInL7bqaf2w0qXG/WS7E8ZybyMs6QJ413B
	 hWagTPu2RoiQ52p8V6FZc0fRSbRcoTw+gX039n2ba15WnsSd8DDKUDJ6VdF2aT5lfF6kD
	 vghAdZYA9X8JlbXdHCEvRuo/qKVWndiASkYpVlROAB++bILo5XduE/VChNp0iTLxHdgCP
	 y+uNpbRyqCMFDP08XgYb3rfvMgG9kq5Oc4bKHPvxHinMKaiitMql94dKgQpqEc9u9OA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794446545;
	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=B/CW36KEeS3ufYaGy3DdV/wzimhKCmAA0IMRiSWriQg=;
	b=lpfbyhhUB1NN58zS4laQJklip3OJub+8fRY7XbyXS1Em/M7xcB6lhB6vsDmtJpQxtFH0
	 wCgBUlgPS/BHgi0u+ENybfortxGx1YUHxk1BAyRgaFKwh/7tFiPacycZW/zlKrO/e7pTu
	 gPYuGJY5P58M1FOElAhVoBEq0q0ujJcZXTtFWonpZwz8Nxn12W8Glbei6ckZzejUxU2Jv
	 rRlyBEPJFvpAaIH/da3lA2vGyvwFGubFTY5gnPuFs/sgsCmo6OCzFzjFrUPhz7gpIJMi+
	 Jl14/6kamkxlPY/s5dr9aUTo3PPs6wdYmd+OKf0yleUxCViJyebFE2j3j0kcL8ypm1w==
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=XbnP+x2M;
	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 BB39E606A336;
	Thu, 12 Nov 2026 01:22:25 +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=XbnP+x2M
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.158
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794446544;
	b=m6BcJKnFSbLuxCo/ps4AcesYyLLwiW9hRm1WJjBpmlm7T5cOKc8rstJZnW1zLIgXcwHk
	 oS5sDbG0TbC8bkKE3Int/uxchomsQeohy7sLhuXVC1Z65swv3ghAwDNRtmUMtaTSa4p6M
	 ZS73377gWAZWOSl/5HKdqR9MwXqjpn8A0GtczjUM6yABxZAlhwqXl6PNnk9vQ5bO3tX6g
	 kruGd8WARMFNZa1FRmQk5JD8jSq7Smc5eNVcnMdMvpHOuh/QNRpKe2fP4EWg8qEd/9obG
	 AfBskGDjAEPCAnnGXPUOX7qtyHCxBDmSdcRL0BgfRQ4qnx7NBroEXBwOWmB+HU+NjTw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794446544;
	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=B/CW36KEeS3ufYaGy3DdV/wzimhKCmAA0IMRiSWriQg=;
	b=mQluvPG5LEoF60pFSa2MXSXX+ow8h0ltsMcUmo8zKHDJoBZcx81s9LNqVysRiTU+L6Ax
	 el1O8M+rSMuOtPurWUBCtnRhB73tQHK0WbUXxhGqlOJsuv6+BK11hE1RvrRyA84aDXbaj
	 iV1mjNSr9tLyIos3/7m+P7XVzUk/JZ6ArsIvsQJblhqlg+PyDv9SkU/5l6p1OWCODF333
	 f49Zwj66w35ShEZETCZo2VYsl2pZv4xgKBn0EskaD6n4/6ggYSbNqXybx1CxZ7VmDeL7z
	 Tv7mTvQS5ewXnSyjYKWoW6mwg7SBLpJqZsorvbhndJBpt911q9SVi0szXEHVfFMZ/Fg==
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=XbnP+x2M;
	arc=none smtp.remote-ip=91.218.175.158
X-Received: from mta0.migadu.com (out-158.mta0.migadu.com [91.218.175.158])
	(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 2906C606A324
	for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 01:22:23 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2906C606A324
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=w2G8knjyk/9VoInzbPgqvCjcKAfz1Xlhb7AVxmgYgcc=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1794446541; v=1; x=1795051341;
 b=XbnP+x2M27vY/iVBBwC00Iitdz8PE1etrJ5FfQk2jXLwZVAc/rZ0qAvSGYeZkotim5J5JoYu
 VFUD1Ib9BA7hDFlEiSY7p4bi6W7a7fwe2/riFaHJ5+VEEctPX/SSu8XUjiM+suEQzj1h3FG75xE
 8CT8cm6uW6LokgoEYpeuS35E=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta12.migadu.com with ESMTPS id 9d76ee2f2cf328f5;
	Thu, 12 Nov 2026 01:22:21 +0000
X-Mizu-Trace-ID: 9d76ee2f2cf328f5
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: <20261111085924.360720-1-sunwenbo@cmss.chinamobile.com>