Article View: linux.kernel.netdev
Article #3022Re: [PATCH net v2] netlink: fix out-of-bounds bitmap access clearing stale mc groups
From: netdev-bot+sashiko
Date: Wed, 14 Oct 2026 02:40
Date: Wed, 14 Oct 2026 02:40
86 lines
8904 bytes
8904 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The code guard is correct.
--
netlink: fix out-of-bounds bitmap access clearing stale mc groups
This patch adds a bounds check to netlink_update_socket_mc(). With it,
__netlink_clear_multicast_users() no longer tests or clears bits past a
socket's nlk->groups bitmap. Sockets whose bitmap was sized before the
multicast group table grew are skipped for groups beyond nlk->ngroups.
> 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.
[Severity: Medium]
The guard looks correct on every architecture. Is the claim that only
32-bit kernels are affected accurate, though?
genl_allocate_reserve_groups() in net/netlink/genetlink.c does a first-fit
search for a contiguous range. It grows the table whenever that range ends
past the current capacity:
net/netlink/genetlink.c:genl_allocate_reserve_groups() {
...
if (id + n_groups > mc_groups_longs * BITS_PER_LONG) {
unsigned long new_longs = mc_groups_longs +
BITS_TO_LONGS(n_groups);
...
}
genl_unregister_mc_groups() frees IDs with clear_bit(), and nothing
compacts the remaining allocations. So the number of live groups does not
limit the highest group ID.
The initial bitmap also starts with five bits reserved:
static unsigned long mc_group_start = 0x3 | BIT(GENL_ID_CTRL) |
BIT(GENL_ID_VFS_DQUOT) |
BIT(GENL_ID_PMCRAID);
That leaves 59 free IDs on a 64-bit kernel, only about 5 more than the ~54
in-tree groups.
With most in-tree families loaded, can an unload/reload sequence fragment
the free space enough to force growth on 64-bit? For example:
unload nl80211 (7 groups with CONFIG_NL80211_TESTMODE) and psample
load psample, which takes part of nl80211's old range
load nl80211, which no longer fits in any free 7-bit gap
At that point id + n_groups > 64, mc_groups_longs becomes 2, and
__netlink_change_ngroups() raises tbl->groups to 128. Sockets that
subscribed earlier still have nlk->ngroups == 64 and an 8-byte bitmap.
A later unload of nl80211 then reaches:
genl_unregister_mc_groups()
__netlink_clear_multicast_users()
netlink_update_socket_mc()
test_bit(group - 1, nlk->groups) /* bit 64 */
__assign_bit(group - 1, nlk->groups, 0)
Without this patch, that would be an out-of-bounds access on a 64-bit
kernel with only in-tree modules.
The v2 notes say Cc: stable was dropped because of this reachability
description. Could this paragraph be reworded so backporters don't
conclude that 64-bit kernels are unaffected?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261013023859.3075601-1-bsdhenrymartin%40gmail.com
Technical Details
Message-ID:
<179194560847.434549.7995246256511325364@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-345973-linux-kernel-netdev=dewy.ruReferences:
<20261013023859.3075601-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-345973-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] netlink: fix out-of-bounds bitmap access clearing stale mc groups Date: Wed, 14 Oct 2026 02:40:08 +0000 Organization: Usenet Network Message-ID: <179194560847.434549.7995246256511325364@kernel.org> References: <20261013023859.3075601-1-bsdhenrymartin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2201787"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3RhfUmjmUrp0RBZUuEt8STAA2Nw= sha256:kKptN4AcR8sq1egYOBj5o/wPNKG1qzoUFX9pZBk+FDs= sha1:6UJ6wR6MdOA3zK8j/B22ZEPRTSs= sha256:94UlFfFToo9L31PMX/Zii+EiAKJZN/dNLANKCHbBmCI= 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 128AB10FFAE; Wed, 14 Oct 2026 05:42:39 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.64 X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=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 0Xro0IcpN1tu; Wed, 14 Oct 2026 05:42:35 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-345973-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 89B6710FFA9; Wed, 14 Oct 2026 05:42:26 +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 409E828CFA; Wed, 14 Oct 2026 02:40:12 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 512E839D6F2; Wed, 14 Oct 2026 02:40:11 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KGmaWVhx" 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 3D960397930; Wed, 14 Oct 2026 02:40:09 +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=1791945611; cv=none; b=Q2OxsiltIdIl008WExTWzPuhGG9Jvh26oLvCcODkc091zMIKWzIIFcqYCHXM+NB/qZj5i6vO51uecCXwzfIJC6WrsL4Br4JNvRjzJZSI0qekLs6zWS/SpDg7IDuAPyKz/HomyoWX+PFjIlFlPUNCQ/+SI0fstj/RAsN3iZbVEWA= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791945611; c=relaxed/simple; bh=X8lj5J4ZUuGxbnbcgCbLyk0XKbqXPSWIhxxb3NYP7qc=; h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=daCJb9IxcUhSHhDuRKYMcDFyQV831V7e3FJFxf2NAnky8JG3zl8zRdpcYFhNHCLgCQ5oRk38nLqycBVC9Wh7RJqso/C0eLhZQGR7iWsM66zAA/fu4gsc0ApcbLp5yj9QBi+6xDpZLnRcYND8FEVqyZiHvZTNUsO2txqBuKCRujs= 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=KGmaWVhx; arc=none smtp.client-ip=100.103.45.18 X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E81931F000FF; Wed, 14 Oct 2026 02:40:08 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791945609; bh=hBkVpvKUPtDDjwwzZ3YUQSxJAQTY2TrMIaX7dOwsj6w=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=KGmaWVhxCW8ztqS65PueVuORxF1wb2xc269m9LFQSeGyCMR/UCuzwjBRR11ZOykIY ksQkcHup27juJiNIjSrxov0ihiu+qk7rU8GqxR9h+pRjsj4+BrrrvrDJR6cvjOvchV Rry8l34ah/adO3pCtnE+2DitNjhepaNK6kYzmBk7CoQnWzOebpo6lMELj0iz9Vj+29 LJ1a5I1whqpBeVe5is6HmUvCR/5WJq6nvKvgqBZkjvjQtkxV1GNKrz2xtGGkiLwoI0 DMmbH6ZdBZCIZ9chbhMGgjVx/5kwl5jw+oUAC3NRFu8r4ZFpEOkpY8fbBlWHsMhpV+ el1qm2eZj8qCA== X-Cc: edumazet@kernel.org, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, nicolas.dichtel@6wind.com, kees@kernel.org, i.maximets@ovn.org, leitao@debian.org, jlayton@kernel.org, kexinsun@smail.nju.edu.cn, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261013023859.3075601-1-bsdhenrymartin@gmail.com> X-sashiko-severity: Medium 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>