From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410149; b=WyJc8MhPMCxgTe4dtyQ5Nj3J2rPMM8971Co/sV2W68SFl7FgIbXuXNHAx+LKaJDUue2v HVd5EC0tGUmYzbauPWP2gTQKe9GmagghQAJ2EPuxo4sH2baDYTcrenNj9YRQxOCrr2hn9 CxSe7fDPxqBxcMZDtym1WLu0/yfF4qLOQDwEZwV7NDrLIlSJjw5DUNwTpJhkAlfUWZahj 7F/a1zm+Q3G+9M1Tkd1/ya3Hynzpx1+HzTh0lU+AX9r+ralGGUSUBxNw6TBqsxNzrYNqD rWrfmdCbpU7jdyGK9t3T3ZxfdNj85J6FT670ist318moHoNrE1yssIijgHOy+0SiqYw== 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=2SqDACfdVFuRn9ZQZJPssbyr7rEQyeyKlaKMDA6BCp3TcWXYCwyMlEw3Yl0ojT51o0+0 mXl0GBXu2JH1aQL4wVfOBRR4YjDj60/L3YmmPm8knfZ9TKloG+R4C31aORMHUs8PVQzle n1xEFC0MYmM4UflaSknwoxH5bdGtdEW/Y/kGwYVxzELCmoDuWo4LtZV7xnBAvOUvmWolj q0Oa3+/0uqfvxFBkh6UNf/e1GCGeNcIM1UjrG03zhEbEB8jeEn5i8Z4UjYEz2TgBQ9Sb1 tnCw9vBvl+mxCkMzevdWfhoVENqhu+dqvDaljIuYeFDto7c4wwuVZnSKd8iV6BLViNw== 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.43 Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43]) (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 3F16D606A334 for ; Fri, 4 Dec 2026 18:49:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3F16D606A334 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-dl1-f43.google.com with SMTP id a92af1059eb24-1b546061d58so2930730c88.1 for ; Fri, 04 Dec 2026 10:49:09 -0800 (PST) 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=XwyMWXFHFPdtRsuDpqs7lGoyPfp0/aRzemDucfXqHlBQ5N88yooKFZqTPvPnZPRDSF bybjPrOXyWwCEoO11U/UeOfacvjpZVhY4Pj6VVaqF3ncDvVaQIh+QCqesQA5Eukt8jgL HhUR/52Ir0vAGid1fUZiDp89MwlWSHsu5IbzftYRSajtDxb6WIP/4ptSXirXPJFPNRqz v1gt3RptK5jIIIAt+pmvNkCiRSQZeWly/BRD18WXYUxEd78ksm8gGR5Au3TGyhR/RZI6 s0RVG20su4EjMABGXYegjiU/2yp20uTDOENRavfMhSfZGZUDNoHntB13qBqX9ghqAVtX l35Q== X-Forwarded-Encrypted: i=1; AL+hErHxeqWctBlSpNXze2HXgeja3yNn5/fY7KmXnPyc01p2RM+Xxd7tH/lEAXRuDxlsb4p81fZu3hs=@vger.kernel.org X-Gm-Message-State: APuU4Z9AjyCZcIfpMOg9sP9yjiulaGIxQFEByKoJl+tAV1m0gQw7TPy/ SXb+hQiEs6V50YfajptqQRoNA7zZbloAXHWsjdkg9BcvgQ9qEn5mbijz X-Gm-Gg: AZFdTZe82tDKHiZl+Sv2cs1tw0t8B7LnmZ5gto8wFqa6UP0epcMo6dgucV6JXkwynqj 6rqPcNa3pWbr0pKLS4+4NprjzUVQ/hPOY5oZMUBMMzwS5ujpcuikulunZQtnWRG/AU9BiaOCZIm 9iRbuXP7BycvA5gfkYTKxwf4fvBHlBGHBSgnWeYeJvyBiVV5BAYWnS4IQrYj+gyKYvrzcmY/3Dn 1TeykHEdv7x/VnJvVOuQCjaKT8H79B54scRB0hS6q9bdNplZ2xrUPz9nQuBOSGJcBHC0Gm69mOy qzuV1U/tFxQ6Qk/JNdUVC5aTBExJc8eZad9xtXoxngjfqrFvD9WAf5v14I+NtP1ihTCTTqm/BKx YQKP2tHbk0xbqExRglpuMWESwup00u5dMS36/U1n0LkE53BShFOZiFoqU/49zB56xypjcUaAJR0 pT9ZJ7A/jv3xbrafUjlxLDEbCCUgdqyZqVutKU3AXbHyjICwWxregQxawEM/Lu5DitEL8KlG/Rr ibfap/qugcM0bJ0fVgDD5dTmMabGMx7ZJUEHs0tdCCtQsxSTWY2TIowIc9ClM24LMyUdDWMvlxq UfzptFTVCcO0ppKXNDjjfaA89wITeKNe12r9fDbAj7EbIJxGS89X+NSRmf+MTYN+Hq1Yz/jZhCT WE3KEq8tnqLob 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) 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) From: Praneeth Balasubramanian To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , David Ahern , Ido Schimmel , Kuniyuki Iwashima , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Praneeth Balasubramanian , stable@vger.kernel.org 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 Message-Id: <20261204184841.1686426-3-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261204184841.1686426-1-praneethb2002@gmail.com> References: <20261204184841.1686426-1-praneethb2002@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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