Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kyuwoncho18@gmail.com
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, sdf@fomichev.me, willemb@google.com,
	horms@kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net] vlan: drop the promisc/allmulti references on the real device on delete
Date: Wed, 25 Nov 2026 13:14:51 +0000	[thread overview]
Message-ID: <179561249161.3135.16028121153100336999@kernel.org> (raw)
In-Reply-To: <179552079831.1290967.13072162433438626338@gmail.com>

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 patch drops the real device's promisc/allmulti reference in
  vlan_dev_uninit(), but it leaves the VLAN's own…

--

vlan: drop the promisc/allmulti references on the real device on delete

This patch makes vlan_dev_uninit() drop the IFF_PROMISC and IFF_ALLMULTI
references that a VLAN device holds on its real device. Since commit
27b918007d96, vlan_dev_change_rx_flags() propagates these flags whether
or not the device is up, and nothing released them on delete.

> diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
> index bca0a3693636c..5286c79188714 100644
> --- a/net/8021q/vlan_dev.c
> +++ b/net/8021q/vlan_dev.c
> @@ -647,6 +647,13 @@ void vlan_dev_free_egress_priority(const struct net_device *dev)
>
>  static void vlan_dev_uninit(struct net_device *dev)
>  {
> +	struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
> +
> +	if (dev->flags & IFF_ALLMULTI)
> +		dev_set_allmulti(real_dev, -1);
> +	if (dev->flags & IFF_PROMISC)
> +		dev_set_promiscuity(real_dev, -1);
> +

[Severity: High]
Can stacked VLANs deleted in one batch drop the real device's reference
twice?

The reference on real_dev is dropped here, but the VLAN keeps its own
IFF_PROMISC bit and promiscuity count. Nothing records that the reference
was already returned. vlan_dev_change_rx_flags() also still forwards any
later change:

net/8021q/vlan_dev.c:vlan_dev_change_rx_flags() {
    ...
	if (change & IFF_PROMISC)
		dev_set_promiscuity(real_dev, dev->flags & IFF_PROMISC ? 1 : -1);
}

Take veth0 <- v1 <- v2, run "ip link set v2 promisc on", put v1 and v2
in the same group, and then run "ip link del group N".

rtnl_group_dellink() walks the device list forward and calls
unregister_vlan_dev() on v1 and then on v2. So list_kill is [v1, v2].
unregister_vlan_dev() has already removed v2 from v1's vlan group, so
v1's NETDEV_UNREGISTER does not unregister v2 first.

unregister_netdevice_many_notify() then calls ndo_uninit in list order:

vlan_dev_uninit(v1)
    dev_set_promiscuity(veth0, -1)    veth0: 1 -> 0
    (v1 still has IFF_PROMISC, promiscuity == 1)

vlan_dev_uninit(v2)
    dev_set_promiscuity(v1, -1)       v1: 1 -> 0, clears IFF_PROMISC
      dev_change_rx_flags(v1)
        vlan_dev_change_rx_flags(v1)
          dev_set_promiscuity(veth0, -1)

__dev_set_promiscuity() only guards against wraparound when inc > 0:

net/core/dev.c:__dev_set_promiscuity() {
    ...
	promiscuity = dev->promiscuity + inc;
	if (promiscuity == 0) {
		...
		if (unlikely(inc > 0)) {
    ...
	} else {
		flags = old_flags | IFF_PROMISC;
}

So veth0->promiscuity would wrap to UINT_MAX with IFF_PROMISC set. veth0
would then stay promiscuous for good, and later "promisc on" requests
would fail with -EOVERFLOW.

If veth0 had another promisc user, the same sequence would turn
promiscuous mode off underneath it. That user's own -1 would then wrap
the counter. netif_set_allmulti() has the same missing underflow check,
so the allmulti path looks affected in the same way.

With the nested order ("ip link del v1", where v2 is unregistered from
v1's NETDEV_UNREGISTER), the counts stay balanced. That may be why the
single-device reproducer in the commit message passes.

Should the VLAN mark that the reference was handed back, or stop
propagating in vlan_dev_change_rx_flags() after uninit, instead of
relying only on dev->flags here?

>  	vlan_dev_free_egress_priority(dev);
>  }
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179552079831.1290967.13072162433438626338%40gmail.com

      reply	other threads:[~2026-11-25 13:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 13:04 [PATCH net] vlan: drop the promisc/allmulti references on the real device on delete Kyuwon Cho
2026-11-25 13:14 ` netdev-bot+sashiko [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=179561249161.3135.16028121153100336999@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kyuwoncho18@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=willemb@google.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