All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: Kyuwon Cho <kyuwoncho18@gmail.com>
Cc: Nikolay Aleksandrov <razor@blackwall.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	bridge@lists.linux.dev, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [BUG] net: bridge: mdb: duplicate sources make the RTM_NEWMDB error path delete a source twice
Date: Fri, 20 Nov 2026 17:13:03 +0200	[thread overview]
Message-ID: <20261120151303.GA2280404@shredder> (raw)
In-Reply-To: <179489219555.3099318.10297266282803881244@gmail.com>

On Mon, Nov 16, 2026 at 09:10:10PM -0800, Kyuwon Cho wrote:
> Hi Nikolay, Ido,
> 
> While testing v7.4-rc3 with an LLM-guided test generator that we are
> developing as a research prototype, we found that an RTM_NEWMDB request
> with a repeated source address and a later invalid source hits the
> WARN_ON_ONCE() in br_mdb_del_group_src(). An unprivileged user can do
> this from its own user and network namespace:
> 
>   WARNING: net/bridge/br_mdb.c:901 at br_mdb_add_group_srcs+0x375/0x4a0, CPU#1: test/106
>   CPU: 1 UID: 65534 PID: 106 Comm: test Not tainted 7.4.0-rc3 #1 PREEMPT(lazy) 
>   RIP: 0010:br_mdb_add_group_srcs+0x375/0x4a0
>   Call Trace:
>    <TASK>
>    br_mdb_add+0x7e2/0x1390
>    rtnl_mdb_add+0x218/0x490
>    rtnetlink_rcv_msg+0x2f7/0xb80
>    netlink_rcv_skb+0x11f/0x350
>    netlink_unicast+0x518/0x870
> 
> br_mdb_config_src_list_init() counts and parses the MDBE_ATTR_SRC_LIST
> entries but does not reject duplicates. In br_mdb_add_group_srcs() the
> second copy of a source finds the entry that the first copy created, so
> both refer to the same struct net_bridge_group_src. When a later source
> fails (here 0.0.0.0, which is_valid_mdb_source() accepts but
> br_multicast_new_group_src() rejects), the error path deletes every
> source added so far, duplicates included:
> 
> 	err_del_group_srcs:
> 		for (i--; i >= 0; i--)
> 			br_mdb_del_group_src(pg, &cfg->src_entries[i]);
> 
> The first deletion frees the entry, and the second does not find it:
> 
> 	ent = br_multicast_find_group_src(pg, &src->addr);
> 	if (WARN_ON_ONCE(!ent))
> 		return;
> 
> We have not seen memory corruption from this; the effect is the warning,
> which panics a machine with panic_on_warn.
> 
> Rejecting duplicate source entries in br_mdb_config_src_list_init(), or
> making the error path delete only the sources this request created,
> should avoid it. We have not tested either change.
> 
> The reproducer runs as an unprivileged user (uid 65534) that creates a
> user and network namespace, makes a bridge with a port, and sends
> RTM_NEWMDB with NLM_F_REPLACE and the sources 10.0.0.1, 10.0.0.1 and
> 0.0.0.0. On an x86_64 QEMU guest with 2 vCPUs and KASAN (gcc 13.3,
> config attached), it warns in every run (5 of 5).
> 
> Checked against v7.4-rc3 (aebb72744764); br_mdb.c is the same in
> net-next (6ff4c5942a30). We found no earlier report on syzbot or on the
> bridge list.
> 
> The reproducer (repro.c) and the kernel config are attached.

Thanks. I will send a fix and a selftest.

      reply	other threads:[~2026-11-20 15:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  5:10 [BUG] net: bridge: mdb: duplicate sources make the RTM_NEWMDB error path delete a source twice Kyuwon Cho
2026-11-20 15:13 ` Ido Schimmel [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=20261120151303.GA2280404@shredder \
    --to=idosch@nvidia.com \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kyuwoncho18@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.