Netdev List
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
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
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	[thread overview]
Message-ID: <20261128152714.GB804035@horms.kernel.org> (raw)
In-Reply-To: <20261120032438.18789-1-sunwenbo@cmss.chinamobile.com>

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>


      reply	other threads:[~2026-11-28 15:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  3:24 [PATCH net v3] ipvlan: update port flags only after ipvlan_set_port_mode() succeeds Wenbo Sun
2026-11-28 15:27 ` Simon Horman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261128152714.GB804035@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=1342116488@qq.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hangbin.liu@linux.dev \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuhangbin@kylinos.cn \
    --cc=maheshb@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sunwenbo@cmss.chinamobile.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox