Article View: linux.kernel.netdev
Article #2603[PATCH net v2] netlink: fix out-of-bounds bitmap access clearing stale mc groups
From: Henry Martin
Date: Tue, 13 Oct 2026 02:38
Date: Tue, 13 Oct 2026 02:38
52 lines
9959 bytes
9959 bytes
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.
When clearing a multicast group of a departing family,
__netlink_clear_multicast_users() runs netlink_update_socket_mc() on
each socket on mc_list, which does test_bit()/__assign_bit() on
group - 1 with no regard to nlk->ngroups. Skip groups that lie
beyond the socket's bitmap: such a socket could never have joined
them. This is the same guard do_one_broadcast() already applies.
With in-tree families the overflow is only reachable on 32-bit
kernels: the ~54 dynamically allocated genl groups fit the initial
64-bit bitmap on 64-bit kernels but exceed the 32-bit one, so the
table can grow there, and a later module unload then touches bits
past the bitmap of stale sockets.
This issue was discovered by Tencent CodeBuddy Security.
Fixes: 84659eb529b3 ("[NETLIKN]: Allow removing multicast groups.")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
v2: Correct the Fixes tag (the clear path was added by 84659eb529b3,
not by the dynamic bitmap commit), drop Cc: stable and describe
the actual reachability (32-bit kernels with in-tree families)
instead of implying generic heap corruption.
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:
<20261013023859.3075601-1-bsdhenrymartin@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-345346-linux-kernel-netdev=dewy.ruReferences:
<CAL4WiipgL26xjM+0+wT-NUVx9ppjQEJj+oShdew-mbzrRVU=dA@mail.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-345346-linux-kernel-netdev=dewy.ru
From: bsdhenrymartin@gmail.com (Henry Martin)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2] netlink: fix out-of-bounds bitmap access clearing stale mc groups
Date: Tue, 13 Oct 2026 10:38:59 +0800
Organization: Usenet Network
Message-ID: <20261013023859.3075601-1-bsdhenrymartin@gmail.com>
References: <CAL4WiipgL26xjM+0+wT-NUVx9ppjQEJj+oShdew-mbzrRVU=dA@mail.gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1944033"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3uBYExWQyVim3j7Ku6qDoI1Fcno= sha256:p2iYuY54/IXq4uLsMjldAHIC9M/+1BiYcUpChN/eRr8=
sha1:5wfq/Cp+g1zrWlDYqCjgblE1txc= sha256:2/2K0Ikff/znYjgsU0w8L5LdMzAiejAWoQiN5/RrZTw=
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 132FC10FD55; Tue, 13 Oct 2026 05:54:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, 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=gmail.com
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 A90j2dufyoSq;
Tue, 13 Oct 2026 05:54:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-345346-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 04BF410FD53; Tue, 13 Oct 2026 05:54:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by tor.lore.kernel.org (Postfix) with ESMTP id 64E4F46F76; Tue, 13 Oct 2026 02:46:03 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id EF3DF480DC0;
Tue, 13 Oct 2026 02:39:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Efpg4r30"
X-Received: from mail-oi2-f8.google.com (mail-oi2-f8.google.com [74.125.231.200])
(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 989334756CB
for <netdev@vger.kernel.org>; Tue, 13 Oct 2026 02:39:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.231.200
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791859151; cv=none; b=HZIR2brZ2K53q1aN88sFeX+OMWNBekFNMi783n4tgiWu6vH5FwGvSY+6vPA8B7EOwkJNt+gs2heUD6bqFQgCA+N/9Sj/FZWzib29jVCK1bvoyH9pr6V/A1MLgul5Z0dPeX8KuCdwPULD2iXu+vdOmYQg8ITL6cJMIPX1OptWkAs=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791859151; c=relaxed/simple;
bh=SmQoF98UqUkTUelc3nldQ/X+CIADCPYpyJdtgYO9Y84=;
h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
MIME-Version; b=eCMOAtEDBrH8IJLVGr5T1q4La5XaspeH+iRWc/M7FjZee7BCULNHLuyUowXXrxybKbdwYQ6dUGvloQJDyqTPAI9uTUloPIpqmnQ73YZKc7i0Oep25f1G8e3QFANCiGTnsAQzqYvdvJ7orQBcJ+vVQfuqfjjXVCjV0RYuuZaJtQM=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Efpg4r30; arc=none smtp.client-ip=74.125.231.200
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-oi2-f8.google.com with SMTP id 5614622812f47-5187c752f46so776052b6e.1
for <netdev@vger.kernel.org>; Mon, 12 Oct 2026 19:39:10 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1791859149; x=1792463949; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=LRbyHHTAjoD6f4mmeHhhXYD+L3yk83DPnnEpnKG2NnI=;
b=Efpg4r30wRrMRuRrE+RQlOf1MEuCdRwFe4MGxOfOW9prTEMqOmVlu9jL/qxmT9Ta3L
XMX8lqmvdrM6FiOuhhcG3wpxyHO8ZB+W1fwP8gAz6KKIDD3zCM1a+EorrIp8JlFkymFs
Nvj7rYA0GhOalTWuRFtAAdRSGkgh26cgOV4RiNufZmngF17izFyjlQ26MTgqH0RhMFx2
qEev/ttkswOHb7D79sFEnhGMZxzhKPdTexmHRswrW82Ba49CvWm0STFjX8UxH4GJGEXO
2JN7EBODl92Y5VbANCM0q0okbsMVSbYCPk9jPmG1xtwCVOzq7FGc00EPeXA7N1BDe/n6
YhfA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1791859149; x=1792463949;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=LRbyHHTAjoD6f4mmeHhhXYD+L3yk83DPnnEpnKG2NnI=;
b=a10OqGj/mJJl4Yn776ilWelE12/4saUWcvusaRrmB1HCtAa6qUxB6DTTbjygY8PK6f
q+cI7sfgz3OjstDWSAWZtpWOlObEbH4NCLSEGuJqQ8A88CA/b2Ow5Z7cB3VE7qTSXUwj
94g5y0ZAbwD/mawJWKNaZXlWfgHeK11hHUee04KyNJzxpzsvl+peBLlrT/oZbl/OTxzi
9ONsUHOB7ggPKWtKpsavOmkcAqadSxLRg/ZyD6g2UYzkAWc268fSZYD+kBEuWrZUAI03
8ezPyJpIqQJaQFEqb5Q7kWMaSGPiAJIM7+2a/X7ucAudHEHVtr/dmNUdk9/wqTb3+kb0
t5qw==
X-Gm-Message-State: AFq9FYKONcqtTxL2kPwgUmji961pOF0Zj82tSWXNk6CwJPesobYmUZQ4
Is+MWid6r95rzPsx+aOKkVKflc3euXKve25I/i/Chflz9xrOvaZ6FDPX
X-Gm-Gg: AYBFou1clB50RmosrinR3VbNvg3Su0dUnR+8HNJB+c/idqHAjzjCM4WRi5EqjwGb/GX
ooaXlnf52D1PJboG2UpNJ0AL6Ra53TU2vodgTO98e8EyOi9x/R78lmyEFDfjdLBDWgjZ3aqy3du
v/V11Yw5uDg0ntdf2l9POS8qK1UK2IWDvCdn9OYNYjHet2bdt135buRR68w5mdqdDMuaBl3npdE
xRS6SQEOafqa8yqg37t6gCrCTYdGfy6jSt6pQc9T3mr6aZDvvDsT78LvaUh3yV+4Sh/QhV163nI
2AaSSkEn7JhH6WIMM1ptuvemZ562ZoV9O+mrTmtL0ld3qSPdqx5536AILeTQ1CdGdSG0xS0fRON
5jMV6WTIqKT1C9+5jhvMh7QnvsgSYEx/ncttZQNZO4iPh2XJeRXD/WXUKZ0oCm7XPp5ofcImU/6
jy8XbcLK1E/tQeyK5BeXZ33xLhPwYB2qYdsftMjrTFFdiGi8Tx+F6YRMNrRNr5L1qMjCJv97hXE
I/CgGiZw+qlzwHlbyAbF+n20XuDMrY/pORkhg==
X-Received: by 2002:a05:6808:c3c2:b0:4ea:1854:b949 with SMTP id 5614622812f47-50c50f297f1mr10349705b6e.33.1791859149449;
Mon, 12 Oct 2026 19:39:09 -0700 (PDT)
X-Received: from localhost.localdomain ([14.116.239.36])
by smtp.gmail.com with ESMTPSA id 5614622812f47-50c1674ddf8sm12798195b6e.4.2026.10.12.19.39.04
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 12 Oct 2026 19:39:08 -0700 (PDT)
X-Cc: netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Henry Martin <bsdhenrymartin@gmail.com>
X-Mailer: git-send-email 2.43.7
X-In-Reply-To: <CAL4WiipgL26xjM+0+wT-NUVx9ppjQEJj+oShdew-mbzrRVU=dA@mail.gmail.com>
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>