* [PATCH net] vlan: drop the promisc/allmulti references on the real device on delete
@ 2026-11-24 13:04 Kyuwon Cho
2026-11-25 13:14 ` netdev-bot+sashiko
0 siblings, 1 reply; 2+ messages in thread
From: Kyuwon Cho @ 2026-11-24 13:04 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Stanislav Fomichev, Willem de Bruijn, Simon Horman, netdev
Since commit 27b918007d96 ("net: vlan: don't propagate flags on open"),
vlan_dev_change_rx_flags() passes IFF_PROMISC and IFF_ALLMULTI changes
on to the real device whether or not the VLAN device is up, and
vlan_dev_open()/vlan_dev_stop() no longer take or drop those references.
Nothing drops them when the VLAN device is deleted, so the real device
stays promiscuous or allmulti for good:
ip link add link veth0 name vlan10 type vlan id 10
ip link set vlan10 promisc on
ip link del vlan10
ip -d link show veth0 # promiscuity 1
Drop them in vlan_dev_uninit(). The device flags are still set there,
and no instance lock is held, so this does not bring back the recursive
locking that the commit above removed.
Fixes: 27b918007d96 ("net: vlan: don't propagate flags on open")
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
The issue was found by an LLM-guided test generator that we are
developing as a research prototype. The commands above reproduce it as
any user under "unshare -Urn", after
"ip link add veth0 type veth peer name veth1". Our test also covers
allmulti and a VLAN that is up when the flag is set or the device is
deleted.
The patch was written with LLM assistance; we reviewed and tested it.
With it, both counts return to 0 in every case, with lockdep enabled
and quiet.
net/8021q/vlan_dev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index bca0a3693636..5286c7918871 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);
+
vlan_dev_free_egress_priority(dev);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] vlan: drop the promisc/allmulti references on the real device on delete
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
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25 13:14 UTC (permalink / raw)
To: kyuwoncho18; +Cc: davem, edumazet, kuba, pabeni, sdf, willemb, horms, netdev
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 13:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox