From: Petr Machata <petrm@nvidia.com>
To: Nikolay Aleksandrov <razor@blackwall.org>
Cc: <netdev@vger.kernel.org>, <tobias@waldekranz.com>,
<idosch@nvidia.com>, <kuba@kernel.org>, <davem@davemloft.net>,
<bridge@lists.linux.dev>, <pabeni@redhat.com>,
<edumazet@google.com>, <horms@kernel.org>
Subject: Re: [PATCH net 2/2] selftests: forwarding: bridge: add a state bypass with disabled VLAN filtering test
Date: Tue, 4 Nov 2025 18:15:52 +0100 [thread overview]
Message-ID: <87qzudn256.fsf@nvidia.com> (raw)
In-Reply-To: <20251104120313.1306566-3-razor@blackwall.org>
Nikolay Aleksandrov <razor@blackwall.org> writes:
> Add a test which checks that port state bypass cannot happen if we have
> VLAN filtering disabled and MST enabled. Such bypass could lead to race
> condition when deleting a port because learning may happen after its
> state has been toggled to disabled while it's being deleted, leading to
> a use after free.
>
> Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
> ---
> .../net/forwarding/bridge_vlan_unaware.sh | 35 ++++++++++++++++++-
> 1 file changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/forwarding/bridge_vlan_unaware.sh b/tools/testing/selftests/net/forwarding/bridge_vlan_unaware.sh
> index 2b5700b61ffa..20769793310e 100755
> --- a/tools/testing/selftests/net/forwarding/bridge_vlan_unaware.sh
> +++ b/tools/testing/selftests/net/forwarding/bridge_vlan_unaware.sh
> @@ -1,7 +1,7 @@
> #!/bin/bash
> # SPDX-License-Identifier: GPL-2.0
>
> -ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding pvid_change"
> +ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding pvid_change mst_state_no_bypass"
I think you'll need to adjust this test for v2, can you please change
the above line to the following while at it?
ALL_TESTS="
ping_ipv4
ping_ipv6
learning
flooding
pvid_change
mst_state_no_bypass
"
> NUM_NETIFS=4
> source lib.sh
>
> @@ -114,6 +114,39 @@ pvid_change()
> ping_ipv6 " with bridge port $swp1 PVID deleted"
> }
>
> +mst_state_no_bypass()
> +{
> + local mac=de:ad:be:ef:13:37
> +
> + # Test that port state isn't bypassed when MST is enabled and VLAN
> + # filtering is disabled
> + RET=0
> +
> + # MST can be enabled only when there are no VLANs
> + bridge vlan del vid 1 dev $swp1
> + bridge vlan del vid 1 dev $swp2
Pretty sure these naked references will explode in the CI's shellcheck.
I expect they'll have to be quoted as "$swp1".
> + bridge vlan del vid 1 dev br0 self
> +
> + ip link set br0 type bridge mst_enabled 1
> + check_err $? "Could not enable MST"
> +
> + bridge link set dev $swp1 state disabled
Here as well. And more cases are below.
I've got this in my bash history. Might come in handy.
cat files | while read file; do git show net-next/main:$file > file; shellcheck file > sc-old; git show HEAD:$file > file; shellcheck file > sc-new; echo $file; diff -u sc-old sc-new; done | less
> + check_err $? "Could not set port state"
> +
> + $MZ $h1 -c 1 -p 64 -a $mac -t ip -q
> +
> + bridge fdb show brport $swp1 | grep -q de:ad:be:ef:13:37
> + check_fail $? "FDB entry found when it shouldn't be"
> +
> + log_test "VLAN filtering disabled and MST enabled port state no bypass"
> +
> + ip link set br0 type bridge mst_enabled 0
> + bridge link set dev $swp1 state forwarding
> + bridge vlan add vid 1 dev $swp1 pvid untagged
> + bridge vlan add vid 1 dev $swp2 pvid untagged
> + bridge vlan add vid 1 dev br0 self
> +}
> +
> trap cleanup EXIT
>
> setup_prepare
next prev parent reply other threads:[~2025-11-04 17:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 12:03 [PATCH net 0/2] net: bridge: fix use-after-free due to MST port state bypass Nikolay Aleksandrov
2025-11-04 12:03 ` [PATCH net 1/2] " Nikolay Aleksandrov
2025-11-04 12:21 ` Nikolay Aleksandrov
2025-11-05 8:44 ` Ido Schimmel
2025-11-05 9:25 ` Nikolay Aleksandrov
2025-11-04 12:03 ` [PATCH net 2/2] selftests: forwarding: bridge: add a state bypass with disabled VLAN filtering test Nikolay Aleksandrov
2025-11-04 17:15 ` Petr Machata [this message]
2025-11-04 19:10 ` Nikolay Aleksandrov
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=87qzudn256.fsf@nvidia.com \
--to=petrm@nvidia.com \
--cc=bridge@lists.linux.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=tobias@waldekranz.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;
as well as URLs for NNTP newsgroup(s).