From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383598; b=qfwMAwYvE56kJVHjv1qs/watl5NVTL8pyJ1ZxVsBAkEAbK1L9PF74T5PWnipB6omIS8c BUsMY7SImd/aAY2fvvbi/tL/VmNKIz7HBdFUuAVuKyl8KMJIoQKBn4my36SuYHUMXdLB0 aBKPr0+pv01UbICFK5FG6oCmqCz5Gfq6BJ+2TbYz7bR/R6bvf21e2qAqYXtIqzQ0cxS1D XsNAdZJPH0D0orbi+i9HbcqG5uUig7AP6zwPgOxYO6yf+SvOGimyJA23DPoZiGQEphq2Z Ee+bJqiLsRF50QZZv8tbWsU7cCmH1l3d9RsLWKe9aww9za6jPjXhT38vtT7WaP+9DnQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383598; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=cH4q7ws4NB0oVdmtbCYxZPwBHVgf8MK6Wl9aavuov1g=; b=heGFjzQ/S3MaBrx7eEO4gTQ5tEHYXCrxgnehYjoe4Ii0m282CxgQU8tFxVDEyeXgZG90 PLSmP+Z6aYR4ycAQaWk9u27R8Dco1SCt2nkbYJT6HkowgfxW6IMvQQaIfr2/9S8QwR4Mw gv4bxGZw8VNAa6rNy1esN82NPSdoYZjx/uCbhY884vnhNDXzbxs1xg9SuiksVmAYLnZbm AYQxuNVaVHBk6iazLgg0YQYJxDmjBzcN3sK8NJ+rw7w3Cp0rk52oNCg6+lyTlpUqkJ17H TProU8XG+v5JFW5cYU0Xv6z+ZJywjOOKtW3HsfRHMZr7P/2tuYxqVBrqtAoNKWODx1Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LmsvyMId; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7ACE606A322; Fri, 4 Dec 2026 11:26:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LmsvyMId Received: by smtp.kernel.org (Postfix) with ESMTPSA id F413A1F000CE; Fri, 4 Dec 2026 11:26:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383598; bh=cH4q7ws4NB0oVdmtbCYxZPwBHVgf8MK6Wl9aavuov1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LmsvyMIdnR3xGx5dZCd2JXLjrIbDmCpp1QuOwMoNZAuCE0nWb/IjwG8961ClX2gnf iL7yn84J5Aku5Suz+h2e5C/Jf6n81fwrDPIwHxFBG3BngqM94uj51Nj4at9xpEBZAo M/ky0VlVYmiXp8EAkrnxZKJOUWhDW1qFzk/wglPs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kuniyuki Iwashima , Eric Dumazet , Hangbin Liu , Ido Schimmel , Willem de Bruijn , Sasha Levin Subject: [PATCH 6.12 291/555] ipv6: mcast: do not pass uninitialized bytes to dev_mc_add() Date: Fri, 4 Dec 2026 19:05:34 +0900 Message-ID: <20261204100620.185816402@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 58f419bfa4c3a6797246a7c4e53a535ee34372ae ] igmp6_group_added() and igmp6_group_dropped() build a link-layer multicast address in an on-stack buffer with ndisc_mc_map(), which fills a number of bytes depending on dev->type. dev_mc_add() and dev_mc_del() then use dev->addr_len bytes of it. Since IPv6 multicast joins and leaves no longer hold RTNL, dev->type and dev->addr_len can change between the two steps, for instance with TUNSETLINK, or when bonding or team change their type. If addr_len grows (eg ARPHRD_ETHER -> ARPHRD_IP6GRE), dev_mc_add() copies uninitialized stack bytes into a netdev_hw_addr, which can later be dumped to user space by /proc/net/dev_mcast and RTM_GETMULTICAST. Zero the buffers. Found by Sashiko AI review of a tun patch, by code inspection only. Kernels built with CONFIG_INIT_STACK_ALL_ZERO=y are not affected. Fixes: 1767bb2d47b7 ("ipv6: mcast: Don't hold RTNL for IPV6_ADD_MEMBERSHIP and MCAST_JOIN_GROUP.") Link: https://lore.kernel.org/netdev/179512665919.3136.5931555157250030152@kernel.org/ Cc: Kuniyuki Iwashima Signed-off-by: Eric Dumazet Reviewed-by: Hangbin Liu Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/20261123124458.205233-1-edumazet@kernel.org Signed-off-by: Willem de Bruijn Signed-off-by: Sasha Levin --- net/ipv6/mcast.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index 9326dd3976bf8..4ad504fa71c3d 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c @@ -713,7 +713,10 @@ bool inet6_mc_check(const struct sock *sk, const struct in6_addr *mc_addr, static void igmp6_group_added(struct ifmcaddr6 *mc) { struct net_device *dev = mc->idev->dev; - char buf[MAX_ADDR_LEN]; + /* RTNL might not be held: dev->type and dev->addr_len can change. + * Make sure dev_mc_{add|del}() do not use uninitialized bytes. + */ + char buf[MAX_ADDR_LEN] = {}; mc_assert_locked(mc->idev); @@ -749,7 +752,10 @@ static void igmp6_group_added(struct ifmcaddr6 *mc) static void igmp6_group_dropped(struct ifmcaddr6 *mc) { struct net_device *dev = mc->idev->dev; - char buf[MAX_ADDR_LEN]; + /* RTNL might not be held: dev->type and dev->addr_len can change. + * Make sure dev_mc_{add|del}() do not use uninitialized bytes. + */ + char buf[MAX_ADDR_LEN] = {}; mc_assert_locked(mc->idev); -- 2.53.0