Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Kyuwon Cho
Wed, 25 Nov 2026 16:37
[PATCH RESEND net v2] vlan: drop the promisc/allmulti references on the real device on delete
Author: Kyuwon Cho
Date: Wed, 25 Nov 2026 16:37
Date: Wed, 25 Nov 2026 16:37
111 lines
14929 bytes
14929 bytes
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.
After that, stop passing flag changes on to the real device. When a
VLAN and a VLAN stacked on it are deleted in one batch
("ip link del group N"), the upper VLAN's vlan_dev_uninit() can run
after the lower one's and clear its IFF_PROMISC or IFF_ALLMULTI, which
would drop the real device's reference a second time.
Fixes: 27b918007d96 ("net: vlan: don't propagate flags on open")
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
Resent with netdev and the other recipients in Cc; the first posting
reached only the four net maintainers (Paolo).
v2: stop passing flag changes on to the real device after
vlan_dev_uninit(), so that a VLAN stacked on it and deleted in the
same batch does not drop the reference again (Sashiko,
https://lore.kernel.org/all/179561249161.3135.16028121153100336999@kernel.org/)
v1: https://lore.kernel.org/all/179552079831.1290967.13072162433438626338@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". With only the
vlan_dev_uninit() change, a batch delete of two stacked VLANs wraps the
count instead:
ip link add link veth0 name v1 type vlan id 10
ip link add link v1 name v2 type vlan id 20
ip link set v2 promisc on
ip link set v1 group 5
ip link set v2 group 5
ip link del group 5
ip -d link show veth0 # promiscuity 4294967295
Our test also covers allmulti, a VLAN that is up when the flag is set
or the device is deleted, and the stacked VLANs deleted one at a time.
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.
include/linux/if_vlan.h | 2 ++
net/8021q/vlan_dev.c | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index c863cdf60f01..c0cfb87d6682 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -168,6 +168,7 @@ struct netpoll;
* @vlan_proto: VLAN encapsulation protocol
* @vlan_id: VLAN identifier
* @flags: device flags
+ * @uninit: the promisc/allmulti references on @real_dev were dropped
* @real_dev: underlying netdevice
* @dev_tracker: refcount tracker for @real_dev reference
* @real_dev_addr: address of underlying netdevice
@@ -184,6 +185,7 @@ struct vlan_dev_priv {
__be16 vlan_proto;
u16 vlan_id;
u16 flags;
+ bool uninit;
struct net_device *real_dev;
netdevice_tracker dev_tracker;
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index bca0a3693636..401ae08f16f4 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -520,6 +520,8 @@ static void vlan_dev_change_rx_flags(struct net_device *dev, int change)
{
struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
+ if (vlan_dev_priv(dev)->uninit)
+ return;
if (change & IFF_ALLMULTI)
dev_set_allmulti(real_dev, dev->flags & IFF_ALLMULTI ? 1 : -1);
if (change & IFF_PROMISC)
@@ -647,6 +649,14 @@ 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_priv(dev)->uninit = true;
+
vlan_dev_free_egress_priority(dev);
}
--
2.43.0
Re: [PATCH RESEND net v2] vlan: drop the promisc/allmulti references on the real device on delete
Author: Hangbin Liu
Date: Thu, 26 Nov 2026 09:14
Date: Thu, 26 Nov 2026 09:14
115 lines
13002 bytes
13002 bytes
On Thu, Nov 26, 2026 at 01:37:04AM +0900, Kyuwon Cho wrote:
> 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.
>
> After that, stop passing flag changes on to the real device. When a
> VLAN and a VLAN stacked on it are deleted in one batch
> ("ip link del group N"), the upper VLAN's vlan_dev_uninit() can run
> after the lower one's and clear its IFF_PROMISC or IFF_ALLMULTI, which
> would drop the real device's reference a second time.
>
> Fixes: 27b918007d96 ("net: vlan: don't propagate flags on open")
> Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
> ---
> Resent with netdev and the other recipients in Cc; the first posting
> reached only the four net maintainers (Paolo).
>
> v2: stop passing flag changes on to the real device after
> vlan_dev_uninit(), so that a VLAN stacked on it and deleted in the
> same batch does not drop the reference again (Sashiko,
> https://lore.kernel.org/all/179561249161.3135.16028121153100336999@kernel.org/)
> v1: https://lore.kernel.org/all/179552079831.1290967.13072162433438626338@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". With only the
> vlan_dev_uninit() change, a batch delete of two stacked VLANs wraps the
> count instead:
>
> ip link add link veth0 name v1 type vlan id 10
> ip link add link v1 name v2 type vlan id 20
> ip link set v2 promisc on
> ip link set v1 group 5
> ip link set v2 group 5
> ip link del group 5
> ip -d link show veth0 # promiscuity 4294967295
>
> Our test also covers allmulti, a VLAN that is up when the flag is set
> or the device is deleted, and the stacked VLANs deleted one at a time.
>
> 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.
>
> include/linux/if_vlan.h | 2 ++
> net/8021q/vlan_dev.c | 10 ++++++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
> index c863cdf60f01..c0cfb87d6682 100644
> --- a/include/linux/if_vlan.h
> +++ b/include/linux/if_vlan.h
> @@ -168,6 +168,7 @@ struct netpoll;
> * @vlan_proto: VLAN encapsulation protocol
> * @vlan_id: VLAN identifier
> * @flags: device flags
> + * @uninit: the promisc/allmulti references on @real_dev were dropped
> * @real_dev: underlying netdevice
> * @dev_tracker: refcount tracker for @real_dev reference
> * @real_dev_addr: address of underlying netdevice
> @@ -184,6 +185,7 @@ struct vlan_dev_priv {
> __be16 vlan_proto;
> u16 vlan_id;
> u16 flags;
> + bool uninit;
>
> struct net_device *real_dev;
> netdevice_tracker dev_tracker;
> diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
> index bca0a3693636..401ae08f16f4 100644
> --- a/net/8021q/vlan_dev.c
> +++ b/net/8021q/vlan_dev.c
> @@ -520,6 +520,8 @@ static void vlan_dev_change_rx_flags(struct net_device *dev, int change)
> {
> struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
>
> + if (vlan_dev_priv(dev)->uninit)
> + return;
> if (change & IFF_ALLMULTI)
> dev_set_allmulti(real_dev, dev->flags & IFF_ALLMULTI ? 1 : -1);
> if (change & IFF_PROMISC)
> @@ -647,6 +649,14 @@ 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_priv(dev)->uninit = true;
> +
> vlan_dev_free_egress_priority(dev);
> }
>
> --
> 2.43.0
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Re: [PATCH RESEND net v2] vlan: drop the promisc/allmulti references on the real device on delete
Author: patchwork-bot+netdevbpf
Date: Wed, 02 Dec 2026 02:40
Date: Wed, 02 Dec 2026 02:40
24 lines
8763 bytes
8763 bytes
Hello:
This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:
On Thu, 26 Nov 2026 01:37:04 +0900 you wrote:
> 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:
>
> [...]
Here is the summary with links:
- [RESEND,net,v2] vlan: drop the promisc/allmulti references on the real device on delete
https://git.kernel.org/netdev/net/c/04ca6fe63d63
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads