Article View: linux.kernel.netdev
Article #14546Re: [PATCH net] ipvlan: update port flags only after ipvlan_set_port_mode() succeeds
From: Hangbin Liu
Date: Wed, 11 Nov 2026 13:02
Date: Wed, 11 Nov 2026 13:02
70 lines
11063 bytes
11063 bytes
Hi Wenbo,
On Wed, Nov 11, 2026 at 02:46:55PM +0800, Wenbo Sun wrote:
> In ipvlan_link_new(), the shared port->flags is updated before
> calling ipvlan_set_port_mode(). If ipvlan_set_port_mode() fails (e.g.
> switching to L3S mode without CONFIG_IPVLAN_L3S), the error unwinds via
> unlink_netdev, but the shared port->flags has already been modified and
> is never restored.
If ipvlan_set_port_mode() failed, the unregister_netdevice(dev) will be
called. Does port->flags still need to restore?
Thanks
Hangbin
>
> As a result, subsequent operations on existing ipvlan interfaces on the
> same lower device operate with corrupted port flags (e.g., VEPA or
> PRIVATE flags inadvertently set or cleared).
>
> Fix this by deferring the update of port->flags until after
> ipvlan_set_port_mode() returns successfully, matching the behaviour of
> ipvlan_nl_changelink().
>
> This issue was identified with the assistance of an LLM-based code
> review tool, confirmed by reproducing the state corruption in a
> User-Mode Linux (UML) environment when ipvlan_set_port_mode() fails,
> and verified in UML that the shared port flags remain unchanged upon
> failure.
>
> Fixes: a190d04db937 ("ipvlan: introduce 'private' attribute for all existing modes.")
> Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
> ---
> drivers/net/ipvlan/ipvlan_main.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
> index f29864db662a..5732b167c5b3 100644
> --- a/drivers/net/ipvlan/ipvlan_main.c
> +++ b/drivers/net/ipvlan/ipvlan_main.c
> @@ -678,12 +678,6 @@ int ipvlan_link_new(struct net_device *dev, struct rtnl_newlink_params *params,
> if (err)
> goto remove_ida;
>
> - /* 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]);
> -
> if (data && data[IFLA_IPVLAN_MODE])
> mode = nla_get_u16(data[IFLA_IPVLAN_MODE]);
>
> @@ -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]);
> +
> mutex_lock(&port->pnodes_lock);
> list_add_tail_rcu(&ipvlan->pnode, &port->ipvlans);
> mutex_unlock(&port->pnodes_lock);
> --
> 2.33.0
>
>
>
Technical Details
Message-ID:
<avRnWUbGFbdfirZB@fedora>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.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-361076-linux-kernel-netdev=dewy.ruReferences:
<20261111064655.233265-1-sunwenbo@cmss.chinamobile.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.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-361076-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] ipvlan: update port flags only after ipvlan_set_port_mode() succeeds Date: Wed, 11 Nov 2026 21:02:17 +0800 Organization: Usenet Network Message-ID: <avRnWUbGFbdfirZB@fedora> References: <20261111064655.233265-1-sunwenbo@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="856777"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:v0licZTsNdnzyWoNGKndNjt87/g= sha256:Sax981p66iA10AgYh/zXMCQR8Tbm9LZahtIHEih10Y8= sha1:FRoI7uaA8AKjN/G6dq03eq342/8= sha256:5rA2lCCj+7icP/rvE28iF5Nx/LnemV9TM2q2hSJXhYA= 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 37280113EF1; Wed, 11 Nov 2026 16:07:24 +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 iJp3b5rvZtDN; Wed, 11 Nov 2026 16:07:14 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-361076-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 65249113EC1; Wed, 11 Nov 2026 16:07:02 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id B6920C2765; Wed, 11 Nov 2026 13:02:40 +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=1794402152; b=KcVXryt0JF3iPaKoGAaOSoCTVj1+wq8Ft0uimqUfaDyWioafpogsg23nqdZIfo0qGAYu d1bYDm9ok+ZlY0rAhXPEq7xMoWkMqmQAn4A9K/jFRJLcyTevCYDbR6uYDJGVpcxhOMSQY Lvj4OmozdrmdJjHY4Bo1wG5X1nDi9qArKd0UACtdY2wnw/FlJz1a63fcyJzxbhCCKcGb5 3FZAZ1vnK3ezdqKDSMR4SmnsFj8NoxVaS8G/1MU9nyfaDy4jfizbTlv6l6VOKJlp3SQxA ateceQJLNb5WLQSyYW5i/tdmoVH7G9nXVD3fzzhvIqMZWab/pzVy3byFO7EVs7j9Hqw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794402152; 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=ZmjCZzov7nJPqrXQ8bns94ZLa5rs46LAAXyoFHfy5LQ=; b=Bx06lS94v4BJwOdeH3XAJBJN3vk0scyL5oreKF1lcjKRyt5s9JTIHSPlm0+D/DJ2Wj89 JVweLN/TBFtZAgAYaazpgAcfARX6fFTLNNtvNGqoHAMs8XLZe5yp0KvyiGyBHR11UUYB/ 2us2ufxPsvp7OG9b8Bq7wfA7t+clj2aQ9KIEl1EV00rpHl+MfvWEIp2cWXN2zeG3JnQV5 UYVP7e+maAl3ly9WogsG5/2kyqMTan+Oey31mflzMNX5R8KtVnofx5rgwd/xE/CwnVKHp Oq6Gn9X49TjxspPaWDZJ2o+gz+Of7qrUk6aGC3Z4kMQLT8tGBmJy70xNV4LT2u6bmtA== 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=o92QQvLv; 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 AD760606A882; Wed, 11 Nov 2026 13:02:32 +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=o92QQvLv X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.182 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794402151; b=QIUbUyxRom+FN/VCnleeebBtvOpXOnfQPP45ulzI7YOLB6JmL/fvhlE4mC6kMJCa/7lV 706PIGqdrnWtnb0xdlapK4h7cLzQeJ5KBZAUdIPrK0Ce7CQl2oD8jKBY/CCLE0KMGNGiP Du33TWbejPSb2a1h1Wpjs+SyztvfewRRq8FUA5yrv3g2P0q8JdPIVUIPkd2/XE+mXWpoO ELfKxXO1Y6iSyQlGikt0G6rKa2RxGBtAaeQov/JAbx0b4QGq2JfdHUJQ6NjXu+GOyIxlZ EM1yUBrTPD0GmOLxmHr0k13xM+do/gmZKUDA0AE50N5JirazWwpYWF4MVlVTE+THztg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794402151; 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=ZmjCZzov7nJPqrXQ8bns94ZLa5rs46LAAXyoFHfy5LQ=; b=vGMNvylcrbV4UHCbmsshLDhpolzQSFq2e2vZZOZzKSzZA/kCC6K/1sELa/6AHHUO0rJR gq0CjcmZkrsG2j/iz70Idveydzp6km9i6KDmT7fH215uc0sYFPOwswVJSQSkmslqyv1sY cDLfqB/TvyIwmvYY8yROAOJTTQeb5qZbIKogIBdYVXs0AKbRVdFA/6+FEmIcu+l9Q+BJO Yy9LD5woJa0hm+xRBpGaSBsjPHpRp0P8VI3Rsc/PrhPF0bzCfTLnpywD8GVME2I1EmUw0 DCWvO/qFF6lDQhjrcD1jyKE7b8qs/e/dZnETVx8+Q0S59xR62UgP1kVHrN96kGZEDPg== 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=o92QQvLv; arc=none smtp.remote-ip=91.218.175.182 X-Received: from mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (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 26A65606A324 for <netdev@vger.kernel.org>; Wed, 11 Nov 2026 13:02:30 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26A65606A324 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=creIoMaV/TDbJJXHBFgieSAYV23IyjnaN5agwm7HWcI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794402149; v=1; x=1795006949; b=o92QQvLvTiVOT85rEhrXY7WZigN9PTIc0TdKCX3N9uXsbP8w3IsKMNjBxKUcp1QcOMBmm2cf ovAPzIzAwpc6hYYnVfCCMwrdJSNL/BwrbAv7h5bqRsYXE5+qz7ZnBSEWv/MIYOBCFBHz8cD/Ecy l3D8gm98aA/wmM+8iMlnGUc4= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta11.migadu.com with ESMTPS id bc78005be9f94d47; Wed, 11 Nov 2026 13:02:28 +0000 X-Mizu-Trace-ID: bc78005be9f94d47 X-Migadu-Flow: FLOW_OUT X-Cc: 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>, Kuniyuki Iwashima <kuniyu@google.com>, Mahesh Bandewar <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: <20261111064655.233265-1-sunwenbo@cmss.chinamobile.com>