From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE4B830648C for ; Sun, 23 Aug 2026 13:32:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787491975; cv=none; b=mQLSwilUek7NzDiJdG+6OEtVPPzOwk/zTgLV5+Nq5kdRtOPHF1J6c3QlZMETbrwHE8odhzkBpJvA+KtEtwjU8wyVAo1CqYYoPuXdvYw1DiFlAGZRlp5hRQBU5OBHglkGuiJitx8TlUmgyWhYK4zYGc5haQERIJ0ls5adxDJSNyM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787491975; c=relaxed/simple; bh=QnsqlWV2+HTY6HhUI51xQCDZ22CyVTT5ZguwayhWJac=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DfMeKwRPz3ybI4ddBm222IrU4EVteWCb/GZMxau2XH5ZGTfG+wKVLokfxV0VThs3/6MMn2sm18aNDkKmLrWVIZvcFXHPmABOKIHsXxiqUjGNNSdr6Jvil6p1uEDOK9qRMPrGzXIQd3FxFd/NzoTlmhSgUUgdsosEY9ek+uktlTA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=blackwall.org; spf=none smtp.mailfrom=blackwall.org; dkim=pass (2048-bit key) header.d=blackwall.org header.i=@blackwall.org header.b=L1k/Q6pB; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=blackwall.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=blackwall.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=blackwall.org header.i=@blackwall.org header.b="L1k/Q6pB" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-c20fb91ed0fso381316666b.3 for ; Sun, 23 Aug 2026 06:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall.org; s=google; t=1787491971; x=1788096771; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=oKNZxXkQOBpNNoBVz2Q1UXI7fB4yjnJyzapqPLmW9AA=; b=L1k/Q6pBsL21Tm6puhF0m8ly5kRjkhPxDnxj4i/qClUFjb9vE3TLBTqX/MhAa95wbe M3gdYmI5c+nkNhfLqGrUsvckDFS2CVl/a4nFAPfowwmoPGkKAt98gxOsxtAXI9DbSX9E IhQIIMEM1vrHbxsP5BxztScxq+bhPfXZlOor6KInHPaKSuqG4FN4gxi+Omz3uJUDNyKu FZD3/jlgv4Bjx5SfRtsN5TYftYIzisUI1PjtIuJT/9e37BV7cYnYBxVMPEvfUF6thRIO j0x4jAaNVU3vPWwzKm+js2ad43z3viI+n4aiByicc73JTKuWZid9fxys0saJP3rbQ0Vk 64mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787491971; x=1788096771; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oKNZxXkQOBpNNoBVz2Q1UXI7fB4yjnJyzapqPLmW9AA=; b=HpI1yZN3D2oajkpbQ0M8UNjunbQypJZUjVsF71qvapzfmBgEtX14s3/AAUMXkAKFP4 f3AI/Q375QGHc42jiJN9XK1lR2YZa48R/m6jD1BsaY9lSJb1W9xBfVXp+/7POfMSmzTq 1YatVw2d4VxsSv2HsAHGxENcnriuElTgEqtqmXuCMlYGJ4yUFSYjWWwpoKSrFZWP6Ouz cU7HZnZNCdyg87sqD37mOUMjVuVICXKa1PRknqm3cqbDx13VGttTB6RK/+BoiQ2xQOzF apYzmSdQk0pgsHPW9kVjeNuT3o2plmWGPw6QUGU9mtOJqLEnuwiwR9v8g9UFKleU9Hx5 MEYw== X-Forwarded-Encrypted: i=1; AHgh+RqzMN4idhh9bzhz9sWE358xeANFHmv9dNOKeFUNgfxmBow24KA6sf43BhPqILe0scm5dMlyB+dAPK8al2M=@vger.kernel.org X-Gm-Message-State: AFuF++mJcbBcAC/joqiyu+6DoD8uFi2zeD7/oIIsJ9oxy/KxR5GToxym 5cnyuW5EGgVENZ9WLYW6pR4t7a98gwEqm/aT+xbhA8vOAPIw/GhUkYsoZUNbK88b6a4= X-Gm-Gg: AR+sD12uXkWfm3rErXyoR3An12mvHo6SQnlBzCexoyF2WB69k7sPn07RBcHNXm6f73s G49523FxG3vSHiRc2/N1ypUeFezlm30V7XvfiedK+wGAkZzqyihff0aBPC4a2+KTmu3JAPxdtYQ lZhyyIKefYfNiktK/4iV6HP3Ocyts6g/QGtr/w55zRMcxaca/VHEposB/VRdl/c3+trnpob3Uk0 a5aklZH7TGZW+rRMdrPtOpXFUnserlyE5Q61r0ND2PDHlBYhak+ru67sJs6wKwAnERVXV35a6N0 RJgJ6iJkAAgI22FMY+eKpZLjubqAoRPHZHisOOLg0h1c9o/yxrDPEHXH2Vdu8vwq2ltEYIQabNt ic+sD3WAJMz4w6iypTUO2o5b0bCCgNRLzEhcOTFx9g1+DwIQ+uvM3ZjXJ3iGBygBLfOFRPl5FMg J9Ml4WGDwHgFeXEEKsPsZxTW/Uuc9GoOvUhob28acEsu9L1xpKoxocga07MvIKLje3fMecABpgL PJkw9w+8HGbi4WyLq8= X-Received: by 2002:a17:907:6094:b0:c1f:9c3b:96a7 with SMTP id a640c23a62f3a-c246a6269d2mr2107478766b.17.1787491971003; Sun, 23 Aug 2026 06:32:51 -0700 (PDT) Received: from [192.168.0.161] (78-154-15-182.ip.btc-net.bg. [78.154.15.182]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c249629563dsm794720866b.17.2026.08.23.06.32.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 23 Aug 2026 06:32:50 -0700 (PDT) Message-ID: Date: Sun, 23 Aug 2026 16:32:48 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] net: bridge: mcast: fix use-after-free of a master VLAN's multicast context Content-Language: en-US, bg To: Norbert Szetei , netdev@vger.kernel.org Cc: Ido Schimmel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , bridge@lists.linux.dev, linux-kernel@vger.kernel.org References: From: Nikolay Aleksandrov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 23/08/2026 14:58, Norbert Szetei wrote: > br_multicast_toggle_one_vlan() clears BR_VLFLAG_MCAST_ENABLED under > br->multicast_lock before stopping a VLAN's multicast context. That is > the teardown handshake: lockless readers gate on the flag through > br_multicast_ctx_should_use() -> br_multicast_ctx_vlan_disabled(), so > once it is cleared under the lock no reader can arm the context again. > > For a master VLAN the handshake never runs. __vlan_del() clears > BRIDGE_VLAN_INFO_BRENTRY before calling br_vlan_put_master(), so > br_multicast_toggle_one_vlan(masterv, false) returns early on > !br_vlan_is_brentry(vlan): the flag stays set and br->multicast_lock is > never taken. br_vlan_put_master() then drains the context in > br_multicast_ctx_deinit() and frees the VLAN through call_rcu(), while a > reader still inside rcu_read_lock() sees the context as enabled and > re-arms it. The port and port-VLAN branch of the function has no > br_vlan_is_brentry() test and flips the flag under br->multicast_lock, > so it is not affected. > > The reader is the bridge transmit path. For a master VLAN > br_multicast_rcv() selects brmctx = &vlan->br_mcast_ctx with > pmctx = NULL, so IGMP sent to the bridge device re-arms the context's > timers after br_multicast_ctx_deinit() has already stopped them. > > Any user able to create a bridge can trigger this, which includes an > unprivileged user in a user namespace, by deleting and re-adding the > master VLAN while sending IGMP to the bridge device: > So much AI slop... at least drop this paragraph which is completely useless. > BUG: KASAN: slab-use-after-free in detach_if_pending+0x412/0x4a0 > Write of size 8 at addr ffff88810ac39918 by task brmc/601 > __mod_timer+0x51a/0xc50 > br_multicast_host_join+0x25b/0x390 > __br_multicast_add_group+0x468/0x530 > br_ip4_multicast_add_group+0x1a0/0x260 > br_multicast_rcv+0x2cda/0x61e0 > br_dev_xmit+0x6c4/0x1540 > Allocated by task 610: > br_vlan_add+0x111/0xb40 > br_vlan_info+0x370/0x3e0 > Freed by task 0: > kfree+0x1a7/0x4f0 > rcu_core+0x7dc/0x10a0 > > Only test br_vlan_is_brentry() when enabling, like the > br_multicast_ctx_vlan_global_disabled() test next to it. Disabling then > always clears BR_VLFLAG_MCAST_ENABLED under br->multicast_lock before > br_multicast_ctx_deinit() drains the context. > > Fixes: 7b54aaaf53cb ("net: bridge: multicast: add vlan state initialization and control") > Cc: stable@vger.kernel.org > Assisted-by: Claude:claude-opus-5 > Signed-off-by: Norbert Szetei > --- > net/bridge/br_multicast.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c > index 75e1e2a8fc83..3ef5d8bbf552 100644 > --- a/net/bridge/br_multicast.c > +++ b/net/bridge/br_multicast.c > @@ -4377,8 +4377,8 @@ void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, bool on) > if (br_vlan_is_master(vlan)) { > br = vlan->br; > > - if (!br_vlan_is_brentry(vlan) || > - (on && > + if (on && > + (!br_vlan_is_brentry(vlan) || > br_multicast_ctx_vlan_global_disabled(&vlan->br_mcast_ctx))) > return; >