Article View: linux.kernel.netdev
Article #18664Re: [PATCH net v2] ipvlan: update port flags only after ipvlan_set_port_mode() succeeds
From: Simon Horman
Date: Wed, 18 Nov 2026 17:57
Date: Wed, 18 Nov 2026 17:57
108 lines
11832 bytes
11832 bytes
On Mon, Nov 16, 2026 at 01:50:54PM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [High] The fix is incomplete.
Hi Wenbo,
This does seem of concern. Could you comment on this?
> --
>
> ipvlan: update port flags only after ipvlan_set_port_mode() succeeds
>
> This patch moves the write of the shared port->flags in ipvlan_link_new()
> to after ipvlan_set_port_mode() has succeeded. The goal is that a failed
> creation of a second ipvlan on an active port does not change the flags
> of the ipvlan interfaces that already exist.
>
> > diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
> > index f29864db662aa..5732b167c5b3c 100644
> > --- a/drivers/net/ipvlan/ipvlan_main.c
> > +++ b/drivers/net/ipvlan/ipvlan_main.c
>
> [ ... ]
>
> > @@ -691,6 +685,12 @@ int ipvlan_link_new(struct net_device *dev, struct rtnl_newlink_params *params,
> > if (err)
> > goto unlink_netdev;
> >
> > + /* Flags are per port and latest update overrides. User has
> > + * to be consistent in setting it just like the mode attribute.
> > + */
> > + if (data && data[IFLA_IPVLAN_FLAGS])
> > + port->flags = nla_get_u16(data[IFLA_IPVLAN_FLAGS]);
> > +
>
> [Severity: High]
> Can a failed RTM_NEWLINK still overwrite the shared port->flags here?
>
> The commit message says:
>
> "Defer updating port->flags until after ipvlan_set_port_mode() succeeds,
> after which ipvlan_link_new() has no remaining failure paths."
>
> When ipvlan_link_new() returns 0, the creation is not yet committed. The
> caller, rtnl_newlink_create(), can still fail after ops->newlink():
>
> net/core/rtnetlink.c:rtnl_newlink_create() {
> ...
> err = rtnl_configure_link(dev, ifm, portid, nlh);
> if (err < 0)
> goto out_unregister;
> if (tb[IFLA_MASTER]) {
> netdev_lock_ops(dev);
> err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]), extack);
> netdev_unlock_ops(dev);
> if (err)
> goto out_unregister;
> }
> ...
> out_unregister:
> if (ops->newlink) {
> LIST_HEAD(list_kill);
>
> ops->dellink(dev, &list_kill);
> unregister_netdevice_many(&list_kill);
> ...
> }
>
> For ipvlan, the dellink callback is ipvlan_link_delete(), which calls
> __ipvlan_link_delete(). Neither function restores port->flags. When
> port->count > 1, the shared port survives with the flags from the failed
> request.
>
> The IFLA_MASTER failure is easy to trigger. A new ipvlan has no master
> upper device, so do_set_master() goes straight to the ifindex lookup. That
> returns -EINVAL for a nonexistent ifindex, or -EOPNOTSUPP for a device
> without ndo_add_slave, such as lo.
>
> For example, with ipv1 on eth0 in bridge mode, this command fails but
> leaves ipv1 in private mode:
>
> ip link add link eth0 name ipv2 master lo type ipvlan mode l2 private
>
> The port->mode change made by ipvlan_set_port_mode() also persists on this
> path. Moving the assignment within ipvlan_link_new() cannot cover this
> case.
>
> Would this need port state to be saved and restored across the whole
> rtnl transaction, for example by restoring it from dellink when creation
> is rolled back?
>
> > mutex_lock(&port->pnodes_lock);
> > list_add_tail_rcu(&ipvlan->pnode, &port->ipvlans);
> > mutex_unlock(&port->pnodes_lock);
>
> --
> Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112064821.85624-1-sunwenbo%40cmss.chinamobile.com
Technical Details
Message-ID:
<20261118175701.GO860048@horms.kernel.org>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-366315-linux-kernel-netdev=dewy.ruReferences:
<20261112064821.85624-1-sunwenbo@cmss.chinamobile.com> <179483705411.3136.2665029224845053782@kernel.org>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-366315-linux-kernel-netdev=dewy.ru From: horms@kernel.org (Simon Horman) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] ipvlan: update port flags only after ipvlan_set_port_mode() succeeds Date: Wed, 18 Nov 2026 17:57:01 +0000 Organization: Usenet Network Message-ID: <20261118175701.GO860048@horms.kernel.org> References: <20261112064821.85624-1-sunwenbo@cmss.chinamobile.com> <179483705411.3136.2665029224845053782@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2655570"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:7/C8uV9t7CkkTtfG1EwdEFl4Hcs= sha256:rL2vMg/FTUsB4/GoRg2bN5QSAygrev+dZxBEw5OJ38A= sha1:nnlnHxwAJdcwtX38fNoHcufoVSQ= sha256:c1OYB8P91hfEjmF03L3fCVLCT1ZNrkq2P00rz8Vwhhk= 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 EA315115352; Wed, 18 Nov 2026 20:57:36 +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 LCngfaraKKF5; Wed, 18 Nov 2026 20:57:28 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366315-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 E3D1111534D; Wed, 18 Nov 2026 20:57:17 +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 AEEFBA1CE9; Wed, 18 Nov 2026 17:57:12 +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=1795024627; b=5Lrn+quP/j7ukI8mbyEThcypwl445ml3QcXq9HjmgYnni0TbazwLq/FBsi/hwuLOuH0g D0faoUSOu6sur8TKpoDryWLmoS2d+pYw0DR1CKGY6j2k20TIUVBMSmQ5h1NEwkjuvav9Y 8y715EJelU0QQ4i8SIncbA7QvWwn8OMpP7CFD7x0g9JG5/YvbSQ2I3DCEt3mX6D5xhHPC Vu1pVsjIqMBA58GNasUz6hgKz6Igllf9d/+G4lbiyleITg8M/Ulra33VDOqTDXxUOlW54 KA0OXWQsDUU4md1bQxkxUI8E1z9BaC70mvu4vQdNMsCv8pV/Z+sa5zpi6k1jkpUSvHw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795024627; 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: Content-Transfer-Encoding:In-Reply-To; bh=228KQJ6URMBlHpySeauUAIbmNzS+ein6ZxweO0f/KQ8=; b=huKCyAU/MZmRq0Ni8pLG6ZwoX0G6hkIQeqLKp5pBGgzJfx3hJ1KrQeSrQI3uLvDoWgqR J/fDZ33W+IsDDVnrCxRAtmaoSy8qwL6n3lLa5iDu3MVyKl51JqmIMk+n3SZA2sl+rePta C2Osxk2EhAEJzV+yyM8/miJMfH9dPT5K1Jro2vhIqrlCmOg0Lp5FCXp5WHFmeUXobpA7t gjZXN/FTpAV+U/1DkdQW6KLKQme8VkK9RJNBg/70fBEHo6k94l420m0hUW0jENZiaWKoK B7PAHdI33ceSl5ashj27E2Ozj4EkvA6WAGbgnWioWh3l0QavNn/vaYCvqp4x/KfOr3g== 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=F43GLJiZ; 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 7FBA2606A339; Wed, 18 Nov 2026 17:57:07 +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=F43GLJiZ 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=1795024626; b=X6zpix4D8KypfuuTqxqDj8quyukqZ5p0hHbBJQLTetmKqBgJGp2EE0f7OkFhCQE9m5Vy OjhXJAX5SSNEFClU4HyXHrTo7nkseqS1Izp+iysmb3ro8k3iTdfocrYecGgGfSGi7IaUn 7WVhLaRJ0aC/KlRJFi8D2MIzxemWWA/MwdluaitGi1041WIDRDGmpKChlehvVzH27LFnj 9QncfPbRRCjS+XuCbECiEn+Vvd2153hl0ZPIPZMEmS1wK6+iL0SaDUJ3a2PRrJ0sP1UM9 bfal3aNnUBKysp0N9fX76/Zw3T1ha7bJg74+B2xej4yk/I3lM6bWkwNRBbMTeTz6Z/Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795024626; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=228KQJ6URMBlHpySeauUAIbmNzS+ein6ZxweO0f/KQ8=; b=HCZwk75Xz2KVkaQRKYCDX234rxasO7m8cr/w3OoZquAU93+4HpSTVzGPBRCu8eul8Sjk oHYlTG0vn8bwUgMwneDN7RcpyZ0PF6OU5v2b4XU75GzUI9YlPkaHB7pAzcDA7EDdpgVkc hmF8/acEkPzXDfPQuq9O1idKb9uqz0XDwo3mIipf1gMR+j9sd3jrhYAV0RH5mZqF0Oe1L uXrM0tBcsyoVFEHPjkSf7TwUJLNYH/CowtKmnPk3WpbNx/VRtg6ZCF7QOAbsSbfKo5vOK 0xgEGbL1p1Vf6Xu2/fY9EZTioF90JCNlFZM6wZFfPqKoRrmZ8vhvPLSrtQZXB5uBJXw== 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=F43GLJiZ; 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 9D106606A325; Wed, 18 Nov 2026 17:57:06 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B6AB1F000C4; Wed, 18 Nov 2026 17:57:04 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795024626; bh=228KQJ6URMBlHpySeauUAIbmNzS+ein6ZxweO0f/KQ8=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=F43GLJiZfqIwmG19kHrjZ/oWi+rmfDHnHV6vSVzCVK+Pl8JNFP2GaqwsbMtrupdDt ulpVekSsQVnAGRenFteVM0l/OTmDeWnA8ccXTEHh3se2ltx+DRn/1HiNeSMCr7k7HK DJphiLiUkV87OYmQiAk2m+8k1lJeOMuDCNhX4EDzR8bvSt8yKaaaVAA8m7cdxTIALW f7R1niRz/+GnxNKInEtwa/JJ/1PZGioWq7eYR5KBd3EXhH1iABMRbjuMNdmhdNGlXf cwGizGrQwPqtVfWz5O5D7Lwws+cYOm2Xgfgr1ok9jdO62jFm+gEAHDSHQ3S8nnArc3 z3JxeeGaazETQ== X-Cc: sunwenbo@cmss.chinamobile.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, hangbin.liu@linux.dev, kuniyu@google.com, maheshb@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: <179483705411.3136.2665029224845053782@kernel.org>