Article View: linux.kernel.netdev
Article #1603Re: [PATCH net] netlink: fix out-of-bounds bitmap access clearing stale mc groups
From: Eric Dumazet
Date: Sat, 10 Oct 2026 08:26
Date: Sat, 10 Oct 2026 08:26
79 lines
9488 bytes
9488 bytes
Le sam. 10 oct. 2026 ร 09:26, Henry Martin <bsdhenrymartin@gmail.com> a รฉcrit :
>
> netlink_realloc_groups() sizes nlk->groups to the number of groups
> that exist at bind/ADD_MEMBERSHIP time. When more multicast groups
> are registered later (e.g. a new genl family), existing sockets keep
> their smaller bitmap.
>
> __netlink_clear_multicast_users() however iterates every group of
> the departing family and calls netlink_update_socket_mc() for each
> socket on mc_list, which does test_bit()/__assign_bit() on group - 1
> with no regard to nlk->ngroups. A stale socket therefore gets bits
> read and cleared past its bitmap allocation, corrupting whichever
> heap object follows it; the corruption repeats on every family
> unregister.
Do you have a KASAN report, or is this from static analysis only ?
nl_table[NETLINK_GENERIC].groups only grows when group ids no longer
fit in mc_groups_longs * BITS_PER_LONG.
On 64bit, 59 ids are free in the initial bitmap. I count 58 genl
multicast groups in the whole tree, 4 of them using reserved ids
(ctrl, quota, pmcraid, NET_DM), so 54 dynamically allocated ones
if every family was loaded at the same time.
I do not see how a 64bit kernel with in-tree families can get there.
32bit kernels could, and then only from genl_unregister_family(),
i.e. at module unload.
The check itself looks fine and matches what do_one_broadcast()
does, but the changelog should describe the real conditions instead
of suggesting a generic heap corruption.
Unless you have a reproducer, I think this is net-next material,
without the Cc: stable.
>
> Skip groups that lie beyond the socket's bitmap: such a socket could
> never have joined them.
>
> This issue was discovered by Tencent CodeBuddy Security.
>
> Cc: stable@vger.kernel.org
> Fixes: b4ff4f0419ae ("[NETLINK]: allocate group bitmaps dynamically")
This commit did not add netlink_update_socket_mc() or
netlink_clear_multicast_users(). This should be
Fixes: 84659eb529b3 ("[NETLIKN]: Allow removing multicast groups.")
> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
> ---
> net/netlink/af_netlink.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index 9fdf964224ab4..8cc655aa927f1 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -1657,6 +1657,12 @@ static void netlink_update_socket_mc(struct netlink_sock *nlk,
> {
> int old, new = !!is_new, subscriptions;
>
> + /* A socket whose bitmap predates this group can never be a member;
> + * don't touch bits beyond its allocation.
> + */
> + if (group - 1 >= nlk->ngroups)
> + return;
> +
> old = test_bit(group - 1, nlk->groups);
> subscriptions = nlk->subscriptions - old + new;
> __assign_bit(group - 1, nlk->groups, new);
> --
> 2.43.7
>
Technical Details
Message-ID:
<CAL4WiipgL26xjM+0+wT-NUVx9ppjQEJj+oShdew-mbzrRVU=dA@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-344097-linux-kernel-netdev=dewy.ruReferences:
<20261010072548.2869465-1-bsdhenrymartin@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-344097-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] netlink: fix out-of-bounds bitmap access clearing
stale mc groups
Date: Sat, 10 Oct 2026 10:26:01 +0200
Organization: Usenet Network
Message-ID: <CAL4WiipgL26xjM+0+wT-NUVx9ppjQEJj+oShdew-mbzrRVU=dA@mail.gmail.com>
References: <20261010072548.2869465-1-bsdhenrymartin@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="1288484"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:s7hpXqMi3OMQgQPwH7HJ6V4sCq4= sha256:CP6B+sI+wghYBRiKHrq25CyJUTfIeSMEdQ/D384sblA=
sha1:rovmGPT3YU2FPXb3gizOZx+CScA= sha256:Hm45T4mbi1rW7P2rY9YLI8b+PJgXmTDCpigR5APzEjw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id DE0AD10F880; Sat, 10 Oct 2026 11:26:28 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.341
X-Spam-Status: No, score=-1.341 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id R66HgiH917Ba;
Sat, 10 Oct 2026 11:26:25 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-344097-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id DA84610F87E; Sat, 10 Oct 2026 11:26:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sea.lore.kernel.org (Postfix) with ESMTP id 2022739723; Sat, 10 Oct 2026 08:26:16 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id E4E51374E45;
Sat, 10 Oct 2026 08:26:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g2HOMi88"
X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id C553635E55D
for <netdev@vger.kernel.org>; Sat, 10 Oct 2026 08:26:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791620774; cv=none; b=qQQQjPebchZTwsWzHsjIeS9Qd+2QgssZJmNWRhunm8muwYmh4P1iGxht2oitA9wmu9qHy6jfJgV48w0Nj6Ys6oypnpFJpecT6JD8AOkDcB/mKQT8WMFGyzvFChVpgmtBSOF9v6sPDwbUWOhWWdpGL2lQ/fe+msxSP156JqAd1u0=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791620774; c=relaxed/simple;
bh=vi5jpLGy+JwHOFQXGt9InSXMZQ//fuL1+427dpdSnQ8=;
h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:
To:Cc:Content-Type; b=oC4uH2RAcNWc6iJFoaZ8oDL52C5tDcFY6iT4yUatVT53s7Z1IS5fyllX5bOrNjCAUFbW3lkkOxwOxy71Nkhum5m11JTNKlpctSMo1uPfODUO2aE6qpXF2Be02LUJ1TYxkZowX8esVXz+Jg/1dy9JZTVzvMom/xUDHPshlQ1I82I=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g2HOMi88; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7699A1F0089E
for <netdev@vger.kernel.org>; Sat, 10 Oct 2026 08:26:13 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1791620773;
bh=OH4d1I58KRGiSRV9Dj+44ocHv/O2DZTJh8ELdSAq85k=;
h=References:In-Reply-To:From:Date:Subject:To:Cc;
b=g2HOMi88/qygg7slQTfltPgS/6rezeYPMPPffhcUgKaWhorTBPERjVpt5UtG4npBg
7urZh2sc7dQIFl6AEwkelipTOYpBNPNhJz6agTRB8aW8TtP5xDv5/JE3+HTydI/WOo
AI9YW3EJQszt7BwQeoF/O8pU4sFRJrrXVDNFlko3H85myTE8JC/3CvZObUXSBn0T5x
AYyckvY7qUosfyXjFjH+83o0oUdpvNOtvVTn8dorAkRFh/RRZcgT5RL2kVtSvZZ+4W
j4reE9Nm4CTlIBfa0FSzmpQs0L7xa4mdaTpJTX9YPxXz3gujK5dr0ve9AwNH5jjQZn
sJkIn356J7CBw==
X-Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-4b1fcd3b1a9so201316b6e.0
for <netdev@vger.kernel.org>; Sat, 10 Oct 2026 01:26:13 -0700 (PDT)
X-Forwarded-Encrypted: i=1; AKwUvByT8l4+fqBJnJGio6raAZLhLzvEzdjPFQUWy4NDOg0SCv7j232xPJjBx+swEyIFRNfhqDLVD7M=@vger.kernel.org
X-Gm-Message-State: AFq9FYKgVfE/3dZ/4X1wSQ/VPX/rwQ+WAYmE4NoAZ6Mu/KAOOWn/VT+Y
jzhs4Vq50RM7RJ4jGUA59vPIbmuxyMNhzMqX42vE4NPRtYqWVD6N9r+VSvfSIDr4LDCxz5WE0AI
l7eKzgtCDoNpzdWCKPEp1RPGX2+eLsN8=
X-Received: by 2002:a05:6808:c2b6:b0:4ec:d580:2440 with SMTP id
5614622812f47-50c56348bd3mr3537338b6e.54.1791620772707; Sat, 10 Oct 2026
01:26:12 -0700 (PDT)
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-In-Reply-To: <20261010072548.2869465-1-bsdhenrymartin@gmail.com>
X-Gmail-Original-Message-ID: <CAL4WiipgL26xjM+0+wT-NUVx9ppjQEJj+oShdew-mbzrRVU=dA@mail.gmail.com>
X-Gm-Features: AclHuK-HBhWUWJd8z0U94No5sZEEaJ0hMqagbNquWcG66cocr2HtoJN_Y12NuYc
X-Cc: "David S . Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Nicolas Dichtel <nicolas.dichtel@6wind.com>, Kees Cook <kees@kernel.org>,
Ilya Maximets <i.maximets@ovn.org>, Breno Leitao <leitao@debian.org>, Jeff Layton <jlayton@kernel.org>,
Kexin Sun <kexinsun@smail.nju.edu.cn>, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org