lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250624174252.7fbd3dbe@kernel.org>
Date: Tue, 24 Jun 2025 17:42:52 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Dong Chenchen <dongchenchen2@...wei.com>
Cc: <davem@...emloft.net>, <edumazet@...gle.com>, <pabeni@...hat.com>,
 <horms@...nel.org>, <jiri@...nulli.us>, <oscmaes92@...il.com>,
 <linux@...blig.org>, <pedro.netdev@...devamos.com>,
 <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
 <yuehaibing@...wei.com>, <zhangchangzhong@...wei.com>
Subject: Re: [PATCH net] net: vlan: fix VLAN 0 refcount imbalance of
 toggling filtering during runtime

On Mon, 23 Jun 2025 19:30:08 +0800 Dong Chenchen wrote:
> $ ip link add bond0 type bond mode 0
> $ ip link add link bond0 name vlan0 type vlan id 0 protocol 802.1q
> $ ethtool -K bond0 rx-vlan-filter off
> $ ifconfig bond0 up
> $ ethtool -K bond0 rx-vlan-filter on
> $ ifconfig bond0 down
> $ ifconfig bond0 up
> $ ip link del vlan0

Please try to figure out the reasonable combinations in which we can
change the flags and bring the device up and down. Create a selftest
in bash and add it under tools/testing/selftests/net

> diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
> index 06908e37c3d9..6e01ece0a95c 100644
> --- a/net/8021q/vlan.c
> +++ b/net/8021q/vlan.c
> @@ -504,12 +504,21 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  		break;
>  
>  	case NETDEV_CVLAN_FILTER_PUSH_INFO:
> +		flgs = dev_get_flags(dev);

Why call dev_get_flags()? You can test dev->flags & IFF_UP directly

> +		if (flgs & IFF_UP) {
> +			pr_info("adding VLAN 0 to HW filter on device %s\n",
> +				dev->name);
> +			vlan_vid_add(dev, htons(ETH_P_8021Q), 0);

Not sure if this works always, because if we have no vlan at all when
the device comes up vlan_info will be NULL and we won't even get here.

IIUC adding vlan 0 has to be handled early, where UP is handled.

> +		}
>  		err = vlan_filter_push_vids(vlan_info, htons(ETH_P_8021Q));
>  		if (err)
>  			return notifier_from_errno(err);
>  		break;
>  
>  	case NETDEV_CVLAN_FILTER_DROP_INFO:
> +		flgs = dev_get_flags(dev);
> +		if (flgs & IFF_UP)
> +			vlan_vid_del(dev, htons(ETH_P_8021Q), 0);
>  		vlan_filter_drop_vids(vlan_info, htons(ETH_P_8021Q));
-- 
pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ