🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27070

[PATCH net 2/2] ip6mr: Take mrt_lock when filling the output list of a new MFC entry

#27070
From: Praneeth Balasubramanian
Date: Fri, 04 Dec 2026 18:48
62 lines
13807 bytes
ip6mr_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 mif6_add() and mif6_delete() hold while
they change these fields. ip6mr_mfc_add() takes mrt_lock when it updates
an existing entry, but not when it fills a new one.

This was fine while MRT6_ADD_MFC held RTNL, like MRT6_ADD_MIF and
MRT6_DEL_MIF do. Since commit a4c98421720a ("ip6mr: Replace RTNL with a
dedicated mutex for MFC."), MRT6_ADD_MFC holds only
net->ipv6.mfc_mutex, which the MIF updates do not take. A new entry can
then be filled from a MIF table that changes during the scan, and its
output list may match no MIF configuration that ever existed. Traffic
for the group is then dropped, or later forwarded through a MIF index
that was reused.

Take mrt_lock around ip6mr_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 the IPv4 twin,
ipmr_update_thresholds() (an LLM was used to turn the comment into a
rule); the IPv6 path was then found by code inspection. The issue was
not triggered, and the fix was only build-tested.

Fixes: a4c98421720a ("ip6mr: Replace RTNL with a dedicated mutex for MFC.")
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/ipv6/ip6mr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index abe2116704c5..cfd864c538a8 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1524,7 +1524,9 @@ static int ip6mr_mfc_add(struct net *net, struct mr_table *mrt,
 	c->mf6c_origin = mfc->mf6cc_origin.sin6_addr;
 	c->mf6c_mcastgrp = mfc->mf6cc_mcastgrp.sin6_addr;
 	c->_c.mfc_parent = mfc->mf6cc_parent;
+	spin_lock(&mrt_lock);
 	ip6mr_update_thresholds(mrt, &c->_c, ttls);
+	spin_unlock(&mrt_lock);
 	if (!mrtsock)
 		c->_c.mfc_flags |= MFC_STATIC;
 
-- 
2.25.1
Technical Details
Message-ID: <20261204184841.1686426-3-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-377553-linux-kernel-netdev=dewy.ru
References: <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-377553-linux-kernel-netdev=dewy.ru
From: praneethb2002@gmail.com (Praneeth Balasubramanian)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 2/2] ip6mr: Take mrt_lock when filling the output list of a new MFC entry
Date: Fri,  4 Dec 2026 10:48:41 -0800
Organization: Usenet Network
Message-ID: <20261204184841.1686426-3-praneethb2002@gmail.com>
References: <20261204184841.1686426-1-praneethb2002@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2834878"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jjHr4VLYM49nBcZFENmud8RO2/I= sha256:cXQzifeXmxbNNZHT7TgRFS+9igy221x4InFWxCgQM90=
	sha1:OMN7zz24rqGLTgxTr8+RgC8icVU= sha256:tyzkO54Sq70Qx202zqRksannxyX1WfYOHCQ+VlQExx0=
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 6D0A3117C9C; Fri,  4 Dec 2026 21:49:26 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.397
X-Spam-Status: No, score=-3.397 tagged_above=-9999 required=6.31
	tests=[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 Nm7oIBjX3SQh;
	Fri,  4 Dec 2026 21:49:23 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377553-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 AF1C8117C99; Fri,  4 Dec 2026 21:49:14 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 7F9A927679; Fri,  4 Dec 2026 18:49:12 +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=DGPtoAvGzQyT9teRs7RVZLZBjSpEWgAtxalXD99p4ZnW4MoG+YAIor8usYRfbiYCRho9
	 IBadOx5UHiyDVfQntNqour6eRfHOaRVzEyWYZQq3ePRoQOQER1zt2EcA0lAjtL7uFb6Me
	 lOgXnbL/mwEFFj4ytkdvYbuj7bAn2kxxdyzLY9WSiqGHMNV8w9kU113IvXGMnT6VtMtr1
	 GT5h9f5W5689kMyA9rQy2E/Yr0MVzSXinyjSNOKegYjSp2IMVTV8neB6PKv2IuY0Wo+UT
	 2ozotqbK+9mTPxFOfDfk4pp70SyX3MX4w5IkpxDy+56FtuLSaN0jSi3XH+tIOUDhruA==
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=WYl/10tPdOJgxIo17Nul636eMu1KlM7XtH405i6h1+Q=;
	b=MH7c+gavkoZGiHXcdSNd9iCXKz2LxXIlxUeSGYQBJCU5od7FO/VxM1bGfQbcNkRtxOPm
	 PCtWZDCJpdBKleg/ZL2u7vQERsz+/6wOawusYZnyVE2fLUCo4bOPKjd8LCQQyXoYRKmgz
	 SM71NPqY4LoSo0gDuqz2zbzePdGP/LXLbxUjQnG/1TktSwM+1CGQgASyaG3NZeYUUwZL2
	 4Q8hSxip25KFkExdXMU+eTfTPCqaxVopxbXWQ5SzXRyLfbY53JMETiGv+GXfzujlwGwmh
	 TJBH/CjktitVbioSF2CAZNe1YYXGPbPs7EnjfxRFyG+PTQpu3+s1VSqJETahPjCvjhg==
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=Sa6tffx0;
	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 63120606A691;
	Fri,  4 Dec 2026 18:49:10 +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=Sa6tffx0
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=JA+Av7wRXwPUo51Be0YNrFL0t2+H5Eaq2WyQoPzdv15rjBdo/xofwQ33qnvXA3pONsov
	 v6Ej49Afm66m99CSQv17Ke/Ls0PMPbRjX4cydfjxJlChWDV8cBY5QmCnxnhwuTjT9Lsrc
	 8Xrl5YVfvCTm2qbaB3LnEq5lL8xutLDTuNICWoKvPlRoz+asVDaFkTH1sYtd/v/WYl2/I
	 uR3WgFzV1BjGoKfVo22MCAc8jc++/L6wfHhUDeZvvdWQ8CsIPrNZ33DqZwIpdJaWWgKl3
	 bx8yauHeQb0fOi3WZfnrFY/GrV4LQbKBTUYzBrmYl5az9x8vaNw/q1sHwx5H8RVwUiw==
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=WYl/10tPdOJgxIo17Nul636eMu1KlM7XtH405i6h1+Q=;
	b=jbr+77YR4cP/JQ3Ishvkal5TLxPi5ZtoKmKk9wFWQ7+ARUGqG8XYUuJqjvDGY6FtRKwP
	 AfklFNMPnXPewdyZZ0uGS08LudRtMatng6GbCN4lYeNum6Eqrcb/1vYxxZli9bgTvlu0D
	 ihUc8qnL0fusWPTR2TNYzsegN/MGtk8vF3hAF5bmbDS808ENaME5yU0f+9hHvplStoNbV
	 Ay+oykCXV72I/W2yz6w71GT4W2tUoKnvwWAPuJFMvVqmQknNtidySeb98Q3F//VHwE894
	 1lIO7oLzbMmD0QcqdfXK5ha/ZpNkj01bbndswoPa0NhTayM6u7i4uerJ+TrTqEC/LCw==
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=Sa6tffx0;
	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 4393D606A336
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 18:49:09 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4393D606A336
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-170135e43c7so2605300c88.0
        for <netdev@vger.kernel.org>; Fri, 04 Dec 2026 10:49:09 -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=WYl/10tPdOJgxIo17Nul636eMu1KlM7XtH405i6h1+Q=;
        b=Sa6tffx0b8jbKonIjO+gQVFdHMxq9yECRkipd1L/4+edMVe41KyZ63rEdAogybEvas
         31CwA6eTN7oEJTgtq0sZg5tPmKagD/9oVIeuw4yzE8xxlkMLsQSxswAION+/lQMu47a/
         SJdkYzXiU9wHAQtrR6cdK56bjMZL2lmWxu30Pw4qmDaqKpCJZdWthuiGqWTYDcCtaUPU
         mUFrKHmjiKdJZ3MXfe8PpupilumFEq0BqcietjCW9UJsazd/5V2PKNvPUB5rR7wmkDLG
         fvy6q1WxKIiStZ35nF7EsD3v/ftX+B5MeEsIu1nJ6ikuC9MKVKIh6qDwBYxnrYCsTLW5
         XInw==
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=WYl/10tPdOJgxIo17Nul636eMu1KlM7XtH405i6h1+Q=;
        b=WUKPByv0HzzritvUYUeUNwA51cVd2JG15XxoUJkCAq6FyqnuWQWOeD1da7gquh3qRD
         h38GqHbxAc7JLDviS5g+xAuXO6CWFP8OGE7FOwfEBLt//0Af6d5Ou7g5SyR4Yc4GCWnf
         uJ3tQn0ZQ4AojlAE9oIOxtiDFA8YGL9j0xWppk/oUys0kpO8ZRBj/1x1PF2LCd5AiaH+
         fDyFV5f7tZBI3sJdnnFiMH3u313G4AJmpD/uvavd8FySo4GaoABF2gOY3JLHAp9xoy85
         WO8Bd1cqOphMQvNbH+OO62r9LdPCafHDirnLgL7Xfv1Paga6/ymNyq6xc5A+iGuQmH6C
         E63A==
X-Forwarded-Encrypted: i=1; AL+hErG7eUu28y+y8Q0AeNYyhjidM3SvW6+Ho65s3KrWCVCG+OsUFvLKyRZfFmRhh0BWU3B6ObZSMbc=@vger.kernel.org
X-Gm-Message-State: APuU4Z9UIfKSjr5zObY2os39wC3OGGkRjx1WvecvpmJ4CwdzKrgJpmgL
	WN44EFuG5iXxYXmNth0USiNGz/fHayyWnkZIXN3SboxKn3Tx73R9uS1b
X-Gm-Gg: AZFdTZcv3jZ1iynNvdPMRTNDsHSxopAANJtvpN4aEfeVrWcodpc3IbChpLe6siXgJYX
	aoCKlY1d6WWCvqnPySCHADcIrWG5Inuy2YAezyAN6p83hUMu59K4NSUofxoD76ZjlecqKU2mzsz
	Y+6DPido8NGc2vWE5XiHd4QaKoB5Kp2QHJzF8GahmpkHPCDhLjzsampbTzCCEwGr+n/yR8x6xvR
	pOxOl7J/UTcwaEKNKbt3wT3nF6iT0wORdDxYNQJllGtXNLG8O5QUZ3dVnIjDbrMSyxHhCXY0JP3
	dXXrUA6BszNPAiap1B0z64ufLRQ40qeM+GCgml4ueLRRdzwrvwY3+IDwEse2WMZCOlsPMOnErXc
	0J9m2z6pQLIqoiuCE5H5DPze59Bg6qAv2hG0RpnSi0ezVVUBqm3YaMB5sM94Xu9OXkrRV89UA9U
	nGUKF/PTA+4YYoxMDD668rqxcBGWU74aJHAk8uBT+54AdBfu9dWrF8jxJQVcJiNgnXrQpCv4pTO
	zEN7QzHNIQc3qSQRB2EdWBHBvFwi3IwOdHil8Ngb7Dpir/sAPA8R2uT+ilJb150KtzRHOuEz3Vn
	bRWjqQiBBD0HQ6UxWpHLdkoy/f8wDV8sXsWVp8VyXVxH22K5jaT4apk3VXv+h35Prv9VXwxA9vv
	X4u9gXTOsRKAu
X-Received: by 2002:a05:7022:b0cd:b0:1b4:f5cb:ebe3 with SMTP id a92af1059eb24-1b5d97b9c0dmr1905828c88.16.1796410148399;
        Fri, 04 Dec 2026 10:49:08 -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:08 -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