From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410149; b=KkhmwKfzETTQFXkym87ZLxqdUBCJz9y7Pz2fecj/TayTsSUjDl7OROQYtCisGbIRxbt0 0H3ou+zioSu7g8wwfsmXwfZwywrZIDWRsOrVmxnzMig8X5JUmmAONDQF20g19ITEVGYpU QERxNQrHWqx3PhQdT+nV3eebO9gsHyshrjUAnUebJiQ2jRZPyeBjJ38fOm9yDfSVdTEVg 66YBc3mdu0QlwepOa5Gg7ZjMuOP3dpvhuG1d7WtMhK2MXoP+/3fuTg3UYrxgFBT+rWa1u 28qNDnXHUdPd4Qpcj2MOdZMnGEt1ziAxWh9Pm3sTeJslkxCu6tmdtclZSgiCrNsHv4A== 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=pw40stDwbVv7e4MayclrDdhDdo1wG9mnsIaTQBfQSpzP4NKScSNwgdSd8j2sS5vORx3y CGGq4BG64l2bWoKUjm4raxZ3l8tEurrFzBqHJcvwLDEaUL2ePbSge0VirE6+NqUGhO0hr duSqsJ3jtEDwj2WaMGr+eufbN/0y1k8SUtpcJS4oI+HpI4cC/766wCFZwKe80lbUZA48L K0A3+1AAen8+94G7hb0pOt1ZAmZmp+OtZz80l6uwxhCD3gevvg+dNUdnYzDg5XsGIuiGK VbC+Zd5d596dRM95mUaj79oqU0gMqB++ABcScV5c9BQtIq+ZoZ7UfAUVYFiHDGgqgaA== 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.44 Received: from mail-dl1-f44.google.com (mail-dl1-f44.google.com [74.125.82.44]) (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 B5BE7606A32C for ; Fri, 4 Dec 2026 18:49:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B5BE7606A32C 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=uaVO8zH1 Received: by mail-dl1-f44.google.com with SMTP id a92af1059eb24-1b5d5fdefe2so1480364c88.1 for ; Fri, 04 Dec 2026 10:49:08 -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=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=Tzjoq2tujs7YZEhJ+Xqufnzdz0NN0yHItQ+BYCZaJ35YosNaDgapVL8VpuMdghDchw 9qOko99Jlj1qnaNPRT953aXM2Ig4Nz0Jl0b1Kp+dSo+FB/QYDXsKUf3Lh+5sYDmYwji1 o5IXQ1YnSG+ny9XMXThuZ023Am+FvY9PQfDTIopIDbEsaDXNaiqmo0b+sRFVa3gaAFWx g56wQjx5+bJofuggvdidquveLtXVn14OmS+YcrYCho1BnpnzDZKgoAiR7jTXBD5p+7d2 LjvnxpuDvNjyEDUTHyP4Ghi0jKl/f43UZYhP7P1gxOUh5YIOkf9EcVQiSShSxsWnyheI kMBg== X-Forwarded-Encrypted: i=1; AL+hErENhWIZfcSwm2VwsXGIaVO4CuRZLFF/hUpjA2ajW1HU2LrzopKRwIqoFLFzej60p+O5wJX8tTsyYt11B8o=@vger.kernel.org X-Gm-Message-State: APuU4Z+wQr479nzb5HJ7XXZpt4aS408u57mhR2xx6cQtsUcYLj09fq0w 67J/aBf4u2dDFqaghzWSsHFY8q7gH2LihO8cURINXIP0a7WrEPCjN+xp X-Gm-Gg: AZFdTZepDlafXnYr5Ywop6J0pviLlPJoZOTM2UQLUtHd9wIkdP/BbEAcXOoaMlxeSpR HDqG8C/AYS6BL49mDprsa0OcmsZ9JeQD8NP4TeLEt0n1N/dLPP/qnTkst2/YDfUz3rM1iLtnJmr qwG8mfKA4+EbiLO0Nu6Sxv5xHJURQZc+HHsY0DyBY+5JfFrbLsia9TBP9KcJMKE6htfP/+4fScw Z3xgo5NCqkhYHgO0yCZ6o+NX98PbVCuquaS0YHCzMPdq9Gpi33j0TF5ZvhhPo+Vmg9ovWV9mefj GVgBl2OS4suHW2wKc+X5a0kHx0AKUqZbcJBOQLCqhJv4xa9OnfmBIlxA2ywai2cUfu62VKDWTSC gxi1wgXPlRHKuuA5wUNBxl3h0VcL+/HX9WkMPV+DYXobFs0vv4r53mZ7rzXmtujWn+n6KQsg1PU gOY8Q/B0y/L5SHwp7x1yOr+aWf+8YoQxvtYYnWewPl3Frk9EvGzIvk/jdQG9xv6wm09Ao9Z6o+/ JEKTqVMwF7E/7rvMa8hLbyeE5KKumtyhBFPTYrUEI1i9KU8e4Lw0xa1tR7RHaeCW5qa3ZtIUUB9 smf8GVzIH0T38s5cgoO7f8VNSlr9lE+rm3koETPVBUpRYr8y8QzHrRjZuPdwf3S1s8E= 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) 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) 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 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 Message-Id: <20261204184841.1686426-2-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: linux-kernel@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 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 --- 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