🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23923

Re: [PATCH net v3] ipvlan: update port flags only after ipvlan_set_port_mode() succeeds

#23923
From: Simon Horman
Date: Sat, 28 Nov 2026 15:27
43 lines
10210 bytes
On Fri, Nov 20, 2026 at 11:24:38AM +0800, Wenbo Sun wrote:
> In ipvlan_link_new(), port->flags is updated before calling
> ipvlan_set_port_mode(). If ipvlan_set_port_mode() fails (for example,
> when switching to L3S mode without CONFIG_IPVLAN_L3S), error unwinding
> calls unregister_netdevice(dev) via unlink_netdev.
> 
> While unregister_netdevice(dev) destroys the port when creating the
> first ipvlan device on a lower interface, struct ipvl_port is shared
> across all ipvlan interfaces on the same lower device (tracked via
> port->count). If another ipvlan interface already exists,
> unregister_netdevice(dev) only drops the extra reference and leaves the
> shared port alive with the updated port->flags, unintentionally altering
> the flags of existing ipvlan interfaces.
> 
> Defer updating port->flags until after ipvlan_set_port_mode() succeeds
> so that a failure inside ipvlan_link_new() does not modify port->flags,
> matching ipvlan_nl_changelink(). Note that failures occurring in
> rtnl_newlink_create() after ops->newlink() returns 0 (such as
> do_set_master()) roll back via ops->dellink() (which shares the normal
> RTM_DELLINK path and does not revert shared port->mode or port->flags)
> and are outside the scope of ipvlan_link_new().
> 
> This issue was identified with the assistance of an LLM-based code
> review tool, confirmed in a User-Mode Linux (UML) environment by
> creating a second ipvlan interface that fails in ipvlan_set_port_mode(),
> and verified in UML that the existing interface's port flags remain
> unchanged upon failure inside ipvlan_link_new().
> 
> Fixes: a190d04db937 ("ipvlan: introduce 'private' attribute for all existing modes.")
> Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
> Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
> ---
> v3:
>   - Clarify in the commit message that deferring the port->flags update
>     prevents failures inside ipvlan_link_new() from modifying
>     port->flags (matching ipvlan_nl_changelink()), while noting that
>     post-newlink failures in rtnl_newlink_create() (such as
>     do_set_master()) unwind via ops->dellink() and remain outside the
>     scope of ipvlan_link_new() (Simon Horman, Sashiko review).
>   - Add Hangbin Liu's Reviewed-by tag (no code changes from v2).

Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID: <20261128152714.GB804035@horms.kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373193-linux-kernel-netdev=dewy.ru
References: <20261120032438.18789-1-sunwenbo@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373193-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3] ipvlan: update port flags only after
 ipvlan_set_port_mode() succeeds
Date: Sat, 28 Nov 2026 15:27:14 +0000
Organization: Usenet Network
Message-ID: <20261128152714.GB804035@horms.kernel.org>
References: <20261120032438.18789-1-sunwenbo@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="976571"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:uTfm6JjoINC4cvgdx2oZ885ZOtA= sha256:nTaij7TXZ2a3LEIVO44ehhM43SoxizY4K9ANL3J32LU=
	sha1:7ENwbqxeNxwC6BeW1LaZ3tm6pHE= sha256:thV4QRcb/ZGShHxRep1O6b7aVgJvb57MnVSGP+ZIdeY=
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 86DAA125F82; Sat, 28 Nov 2026 18:27:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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 (2048-bit key)
	header.d=kernel.org
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 MuhvNHdoWVVI;
	Sat, 28 Nov 2026 18:27:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373193-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 67EA5125F76; Sat, 28 Nov 2026 18:27:24 +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 539432925D; Sat, 28 Nov 2026 15:27:20 +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=1795879639;
	b=1XgYzrJeno+1BGuwraPcfFF5q2r+FYcI4aWVSE8pMNf0mwyfB9tmJr3EkwKUaZ6goGHQ
	 25eJupzEa8FM1x1Y/Emd2EKBV7TsNeI/qyFWtEQ8+PIY1Ma/PxbVW/Alv0Lnkg6NRjEoJ
	 p88GvTEtZA5HHAyoKViCL4HTfenOiOwLENufpkgnKjbGMRPKgE1uzZp+wivC8jHKPFZRg
	 GOtbLoLdAznYgO/HzOb+Icd9whfopylFGvF0hWMjq66K1d5ZwLMlnisG0mQ7FyLsyMBJT
	 BxiCnqV/fjEfuGiRKo6ralBfhj5RjnEiMr8AtL2MTe9/jy9yQIj7xCRAb4kc+1KxRJQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795879639;
	h=X-Original-To:Received:Received:DKIM-Signature: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=Ou38e2SxRsowsC4OABL8WDLpn3tpSXaemiOSd+5fjw0=;
	b=LL5FAzJx3WQF/q5zK8vHoGIHQo8fztbjoPLswSl8oen9fH4DAjObUfgV8CEq3/L/20lt
	 SYunuuxmFQHcBNBEMXush73mdfKJxLU+2LdSENSJbx3rZdWz7srnVTged8T2YDRLwnzBA
	 9n0HzkDRjylipHf/cRUs+K2UPBm+7EtF4z6nU4/FMUVc1y/kUXiyIMPKFQN7cANu8Dj0O
	 2cWBClk4hFn3ozWSnPC10gou7NkE3bK5Vlb10AVdv/UjWs02cDIdTNS57C6YyIVhiytoh
	 Hh7jXujinCNYm9UD6u6U+/oMKoZSJQUfU98TAlTp7wEzaXeTDb8lRlSTHNlOYVABvvQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iZJUxCOd;
	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 CD067606A32A;
	Sat, 28 Nov 2026 15:27:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iZJUxCOd
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795879639;
	b=nmV6dhrUG1EGw4O7AKATnr6EQHr8Io9Cv0IkfNxOHCxzXTGwY3KZB9lnq/8aOiXJB0tp
	 1hSml0aVtkmvGgPnZfQqNmj1VDtcNK791sQjPxxGhU6BxuwqdzzsSLYpY1lFLwkGyr2dH
	 X/37dpS8ACukaCLIt6aGMJAQ48x2SOT54f44xnhJR2OGHfBMSJpWMrAQ/jl5VzVIUqzuU
	 v54PGSnoq54+Im60JHNqo44JiMIOiMzdtBI43QIy9RE3R/yYRJt0EbMF5so+7gVCP59Fi
	 i1HZV1R5FxAgUm+4MS4FQLndG8gxwfhPq5cineRIH8M1kbfK5bk64nUlvshqDXxZWPw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795879639;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=Ou38e2SxRsowsC4OABL8WDLpn3tpSXaemiOSd+5fjw0=;
	b=rYh5bd7z4nmmBqDUhKmGoX7yGfvq/k7b/XQJcYEUpngfLamQwGpSWmk4dCDq+B53K2PF
	 3bA0+4WWJYV0m7Jz+auSLgGbG7s+f0UzQa4x70BFyeQrpGpw23YL87iwXL3RDMSI0Y8zU
	 6DUOBdQIVyrLe/46gdsSUkskSaJoYdEa32PQ2YjkT46oqL/kdlk3LnWuC6Jk7aST6X9Pm
	 lt/ozxOSYoy9ayVTnyBybKV5d3LAdXCpwvTd9ULhemxDcUEnlP8laz2hH4QokUwAPDS7h
	 IY2OLHM+kPi9ppaR3ynq/3cBDv2TSaWTqSM8SQCNaznN1g/jSVweB/Bd026n+hdDbuw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iZJUxCOd;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAC69606A31C;
	Sat, 28 Nov 2026 15:27:18 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B7DF1F000C1;
	Sat, 28 Nov 2026 15:27:15 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795879638;
	bh=Ou38e2SxRsowsC4OABL8WDLpn3tpSXaemiOSd+5fjw0=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=iZJUxCOdwutyskFfl6Nb4zm7dBqtJXvwYO+bh2MC87lvlGU3MyDxQ4K0dwqpCw0wA
	 xfW6wCv5woDXumjsGRXQbYKZma3P1TFHy0m5MBpvx5xH/RA4XJi3ATDjTwsDko8sXV
	 8c1WZIY6fowr9OA8ZmM7C7omtMAThiXMf/IVgkzxzLpAmmvqnyMLEW4Htq7YbbHjzU
	 adN108Yrrx8tKaSqRsFeWupRih5VzqyrtRC8lEHwqDndnj8eXl/9weLYjQ+cIM/sCx
	 csd9yYzb8aItDIPr/IiIwDf/Oktj007rBkgshR8ZjaL2KMF4PG2EsGoilxkWDRmWX/
	 /vZhCJQ914eHg==
X-Cc: Mahesh Bandewar <maheshb@google.com>,
	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>,
	Hangbin Liu <hangbin.liu@linux.dev>,
	Hangbin Liu <liuhangbin@kylinos.cn>,
	Kuniyuki Iwashima <kuniyu@google.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: <20261120032438.18789-1-sunwenbo@cmss.chinamobile.com>