Article View: linux.kernel.netdev
Article #27071[PATCH net 1/2] ipmr: Take mrt_lock when filling the output list of a new MFC entry
From: Praneeth Balasubramanian
Date: Fri, 04 Dec 2026 18:48
Date: Fri, 04 Dec 2026 18:48
61 lines
13756 bytes
13756 bytes
ipmr_update_thresholds() reads mrt->maxvif and mrt->vif_table[] to fill
the output interface list of an MFC entry. Its comment says that it is
called under mrt_lock, which vif_add() and vif_delete() hold while they
change these fields. ipmr_mfc_add() takes mrt_lock when it updates an
existing entry, but not when it fills a new one.
This was fine while every caller of ipmr_mfc_add() held RTNL, like the
VIF updates do. Since commit bddafc06ca5e ("ipmr: Don't hold RTNL for
ipmr_rtm_route()."), an RTM_NEWROUTE request for RTNL_FAMILY_IPMR holds
only net->ipv4.mfc_mutex, which MRT_ADD_VIF and MRT_DEL_VIF do not take.
A new entry can then be filled from a VIF table that changes during the
scan, and its output list may match no VIF configuration that ever
existed. Traffic for the group is then dropped, or later forwarded
through a VIF index that was reused.
Take mrt_lock around ipmr_update_thresholds() for a new entry too.
This was discovered by a static analysis tool: Clang context analysis
checking the locking rule in the comment of ipmr_update_thresholds()
(an LLM was used to turn the comment into a rule). The issue was not
triggered, and the fix was only build-tested.
Fixes: bddafc06ca5e ("ipmr: Don't hold RTNL for ipmr_rtm_route().")
Cc: stable@vger.kernel.org
Signed-off-by: Praneeth Balasubramanian <praneethb2002@gmail.com>
---
Notes:
This was found by a compiler-based check, part of research at UCSB SecLab.
The locking rule stated in the kernel-doc comment of the called function
was turned into a Clang context-analysis requirement (__must_hold) on that
function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every
caller. An LLM was used only to turn the comment into a machine-readable
rule; the report itself comes from the compiler. The patch and changelog
were drafted with Claude Opus 5.5. I reviewed the patch and take
responsibility for it.
Testing: builds without new warnings with W=1 (x86_64, clang 23,
allmodconfig). Not runtime-tested, and I have not observed the race
myself.
net/ipv4/ipmr.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index edb6038ce956..969d5fd9f053 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1305,7 +1305,9 @@ static int ipmr_mfc_add(struct net *net, struct mr_table *mrt,
c->mfc_origin = mfc->mfcc_origin.s_addr;
c->mfc_mcastgrp = mfc->mfcc_mcastgrp.s_addr;
c->_c.mfc_parent = mfc->mfcc_parent;
+ spin_lock(&mrt_lock);
ipmr_update_thresholds(mrt, &c->_c, mfc->mfcc_ttls);
+ spin_unlock(&mrt_lock);
if (!mrtsock)
c->_c.mfc_flags |= MFC_STATIC;
--
2.25.1
Technical Details
Message-ID:
<20261204184841.1686426-2-praneethb2002@gmail.com>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377552-linux-kernel-netdev=dewy.ruReferences:
<20261204184841.1686426-1-praneethb2002@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377552-linux-kernel-netdev=dewy.ru
From: praneethb2002@gmail.com (Praneeth Balasubramanian)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 1/2] ipmr: Take mrt_lock when filling the output list of a new MFC entry
Date: Fri, 4 Dec 2026 10:48:40 -0800
Organization: Usenet Network
Message-ID: <20261204184841.1686426-2-praneethb2002@gmail.com>
References: <20261204184841.1686426-1-praneethb2002@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2834929"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:kGJQExmuxpq4o4AyameV+ezfP2o= sha256:Ac784O5UOAJVeutFzpUCJs7aPSP6cTCFen9Uz0HepA4=
sha1:BLrIVVw5XdrnIpeH/56aaSJZ350= sha256:E0CCyPIZL94ABaFUMA8TYd8VBWsVU5K25ymTgq9prZI=
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 25285117C99; Fri, 4 Dec 2026 21:49:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.297
X-Spam-Status: No, score=-3.297 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.001,
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 Mt9NLWFF3Mt2;
Fri, 4 Dec 2026 21:49:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377552-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id B2FEE117C9A; Fri, 4 Dec 2026 21:49:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 3AC423FC84; Fri, 4 Dec 2026 18:49:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796410150;
b=YEoLrEDeS8h02fNWAk3lpkJdwg+gj5MwS5y1SNWeydkBqxFnMz8/qXYxYpgHF1d6GQnv
TxCoPY7Bv9qQ02Tu1xkECrGMD/Mnanxx8eKktsgXmYffwbX5TW8Inl4tMRqoel/e9BssK
k2FzAR06ME79jYfmqKJ8cmEZ0UmG041NDhoVeP83mOSaXHTm3/DnrzKWA/KQ4lyDvSm0M
HG5RDsxtjQIbif98DCqf04suOaa9w7oo17LHKjIyYQ+3uuhG/kDrZPh7k+Nc5qfKKF1am
QyAIVjECOMNbR2MzZ3bWADJTRRUo8eof/JUMpZ8V0kijCItavhOY3CJ5sCmgl3dclaQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796410150;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-Id:
X-Mailer:In-Reply-To:References:X-Mailing-List:List-Id:List-Post:
List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
MIME-Version:Content-Transfer-Encoding;
bh=46Lo358KyT2BiDBrCF+oXHubf4ZL1HhLfTDLIUNoSe4=;
b=1UQu7bXYZBPO5tSiFh6Jm2i9LAoMXUuA1xDDuY/0EjSSom7v4J25JlKeDxObGl9dmXlM
f2JcO+21CR4YA8RAZWubKPoUywjRNvqVTB4QbpS11PCEwGds3N4nRnbeKBTMMaweTaS/K
LpsS4Du3QCaiFqvrVKIyPZwzWEPHOcLPCbsLC8AnfytwCRHYGdttn1pifQia/PskHDstZ
gqb1xrhDqdTith4UTVrxGk5jHGP2sCt+GL8mgFisiAVHbuNR0JV/N8C/AnO6/784yyEUU
g5CRByeKu9+HQ5rg46ZiBvbv4MMnV7pMoZfiGIapKmzcBAeRUnUvJaEtJx1hojK6Cew==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=uaVO8zH1;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id DC5CE606A685;
Fri, 4 Dec 2026 18:49:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=uaVO8zH1
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.45
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796410149;
b=P0b59jgKyRKU42d4h/gO/1vBz5B6JQibbWs7Qp4AlA74Sm7C01eYdvDXZs3/xxbtXONh
kggR7vhI9E3QzjRHxxRGUmpIBX/b9UPWCLsEO/8jhd5yeT7Aw/UUTepo/dHGWp1t+l4qz
aBJ2ozsC+56NvARSktDASPkzkEI3vnNE62xXjvjXYlvGtft5Jzg6+Xdulf9gKDR6CWX04
Vis2vdygis70a9fxRUCx9WDNf6ax9sph3lwijQs75Y3yS7H4umQmuWItAclWi0rtzTL6N
d9TeJX08pG+Ttq1Ie/JQG+2j4jLyi+lUDKGAca0RdYWkJoI9lT94Ha46DFrLmHDwUvQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796410149;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:
MIME-Version:Content-Transfer-Encoding;
bh=46Lo358KyT2BiDBrCF+oXHubf4ZL1HhLfTDLIUNoSe4=;
b=ArwT67u7M8bEoDHSwMbAiKcpJ6S3dm44M6smJuy2bgf5Pp3VSfcq8ZadAlIUasI+/IPJ
wqjp9pQIglztqPopDSTrRUbhADjUZjTQlQ8D7VGu+XIb8okhit5iAi3SGrueY1RpYfeph
U6AtG6vjyu7gFM9Ou9zJiOFcOLk8Dv/TK/IHwTtjBGFNIS5m+eGQZKDJ5y3+6QUWJWICz
f4dOLxk14MJcEkrK5ClqlHl9e7lMu9nVzXBpARGFOVN6NRgYjGFbRbtBzmIMRKRlvb5SI
GQIKPJQu6NO/awRqDXiTR/pFDIspG5LE12ZWXzxA0/1aY8C952sv0sEXt5s7sQJN9FQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=uaVO8zH1;
arc=none smtp.remote-ip=74.125.82.45
X-Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9276606A32D
for <netdev@vger.kernel.org>; Fri, 4 Dec 2026 18:49:08 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B9276606A32D
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-dl1-f45.google.com with SMTP id a92af1059eb24-1b5d5fdefe2so1480363c88.1
for <netdev@vger.kernel.org>; Fri, 04 Dec 2026 10:49:08 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796410148; x=1797014948; 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=46Lo358KyT2BiDBrCF+oXHubf4ZL1HhLfTDLIUNoSe4=;
b=uaVO8zH12rpjYGT/AB4RFYc2flkEerPcnwLVwCwtMDMnmUTnh7pE9F3LnDK+ADXw7i
nn+DCALYDVpZAbxbIP0uwcph0QYxKYP2xmhFTvCbMmZAQeY5ERcm9d1KiCf1lTrr/njd
GSMIuDX1z1+typPw0M9B636AjZXewuuL3dkn0K6xBqIiIXpx0/abmyX9tgZIlItI6hcD
1Dz75qNJMISI+FB0GYwaodJM5ZHiOwgszA9vTj2MlZElUhRYvHBf7UlUYFlb8cv6nYIC
j5vNpfFi5fB0YmsVjk3s9SROEd4fPpEulBfOFE+3I2gNoPQKg1RcLa7NWm/BxjEnJwKW
rjBw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796410148; x=1797014948;
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=46Lo358KyT2BiDBrCF+oXHubf4ZL1HhLfTDLIUNoSe4=;
b=FigJ1TkOrq5brEu6FDrLK3IMMC9gqc3TZTNaknFFODS9XYJy+0fBHbFBtIEFlpvNvr
GKlU4st6T2uMu3zCSY3+tSKtSMMOHgkWZFGGhvFh7vmCgktcGU5RP9d2rLeEWRSS7yJr
P69o9w4NtNxhITpDL0Bxb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6mMzIaApv2DDpty0NifY6izNvjQYE=
X-Received: by 2002:a05:7023:e49:10b0:19a:8e3e:530e with SMTP id a92af1059eb24-1b5d70ccb48mr2507478c88.8.1796410147709;
Fri, 04 Dec 2026 10:49:07 -0800 (PST)
X-Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37])
by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d6323d8esm10166434c88.0.2026.12.04.10.49.07
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 04 Dec 2026 10:49:07 -0800 (PST)
X-Cc: Simon Horman <horms@kernel.org>,
David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Praneeth Balasubramanian <praneethb2002@gmail.com>,
stable@vger.kernel.org
X-Mailer: git-send-email 2.25.1
X-In-Reply-To: <20261204184841.1686426-1-praneethb2002@gmail.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list