From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6484B606A87C for ; Wed, 4 Nov 2026 19:28:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=byXXsxYw Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jKb8F143Fz30V4; Thu, 05 Nov 2026 06:28:29 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2600:3c0a:e001:78e:0:1991:8:25" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1793820509; cv=none; b=otPfP3jWmPymI4dSg0QudPHDXHVTsyelXkgwAKPCJLjwq8oIM4n3FT0joEXUPqf+vYwbuQ0H0QankXbdYviyNsyfUzPAztdY68XCbne1t87p5Mv++O6JCc1qM2AzfQBgXnety+HX5VELVOI4lrqevejXeSY3+zbjAbfWuT96YmZF/8gwZviKrh9Eg6Y9lNelpmPXuQHKlhRxsv1wc3dV+zwdYDKCle9HpwvInE9uyUbiiwMwJZJysHF5CHg9ZqxgRHmlVvBepA3tWEpJySIiK4zMApOQQ8JVPw8JUN61MSzax/fUSi3ddje2DzU+rWtHPeNnPUzXjFR+m4wH+f8vWw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1793820509; c=relaxed/relaxed; bh=gGh9qQAToZE5wrWgcgjg72Buy8fnK2LgswQGjbfg87A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U2pW0pCRyQAdjnDS06IkjRS+u8Se8Elnc+kRyYl7PaCGdktiHsa2E4Y3YA47pkuOLCfkS879QH0TBKFygHfrDMmoTwb0ell99fj19kk8G7CNgdn3u1YUUQ2pKAfl5tyF5LWIenSWob7NkZKVxXsel6rEfTh18VSGZZGT2mTgswuvvAPSEqLTIzj/drE2ve0TFQYXva/RkQRPd5Gd9OI+Y1kHm4E4HrV9vVm8nk+AQbQqebBL1amEl+L3RmGEioTXD6gIHrnYRIhe5o2bEfJsgG0VqoSd1ISo4q8y2uh+aqy/+pTO5HVE61bDekFJixweRvl9YfPWcg39R27zLyMxXA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=byXXsxYw; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=brauner@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=byXXsxYw; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=brauner@kernel.org; receiver=lists.ozlabs.org) Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4jKb8D2NHFz2ygg for ; Thu, 05 Nov 2026 06:28:28 +1100 (AEDT) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 625A1418AD; Wed, 4 Nov 2026 19:28:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F5B61F00A02; Wed, 4 Nov 2026 19:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793820506; bh=gGh9qQAToZE5wrWgcgjg72Buy8fnK2LgswQGjbfg87A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=byXXsxYwwlEEzVCdRuUNyOsLcAI+STSe55KsEGh4BJlF7vBluSLDj7xpOzM7lQKQ4 uvVISAxqyAtBDBpIeAqQ8oGCN092NLKfSJVGkw+BNmr8dzLnc2og/C96qttPNVfs93 XwoNGni8iN/tC1YXe5AYuIZI6WQoC4tduRrr4C9eyl+yKXSLVR4nkDnOPM7geCc4uC ftqw04+u+hakNSgLNjIxLDcE9txZXHVKfyY+39OrDntZluhV0w61HCQ45L1DfF68Lg gd5gAsNrRK9OI6wE3u0lJntjeJWYJdgnxgjqgVsDg+10MAEUapfIUfBLUOI675u60V wveEeYDFgw+HA== From: Christian Brauner To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Jann Horn , Josef Bacik , Chris Mason , Jeff Layton , NeilBrown , Eric Dumazet , Thomas Gleixner , Al Viro , Jonathan Corbet , Christoph Hellwig , Greg Kroah-Hartman , Joel Granados , Kees Cook , Jan Kara , Jan Kara , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-um@lists.infradead.org, linux-wireless@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, ntfs3@lists.linux.dev, platform-driver-x86@vger.kernel.org, coreteam@netfilter.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org, linux-sound@vger.kernel.org, netfilter-devel@vger.kernel.org, dri-devel@lists.freedesktop.org, ibm-acpi-devel@lists.sourceforge.net, jfs-discussion@lists.sourceforge.net, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cifs@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-mm@kvack.org, linux-sh@vger.kernel.org, linux-usb@vger.kernel.org, samba-technical@lists.samba.org, sparclinux@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-doc@vger.kernel.org, linux-serial@vger.kernel.org, linux-atm-general@lists.sourceforge.net, Takashi Iwai , linux-input@vger.kernel.org, linux-raid@vger.kernel.org, linux-ext4@vger.kernel.org, linux-modules@vger.kernel.org, linux-debuggers@vger.kernel.org, "Christian Brauner (Amutable)" , Chuck Lever , stable@vger.kernel.org Subject: [PATCH RESEND v2 50/51] proc: don't pin a symlink's entry while readlink() copies it out Date: Wed, 4 Nov 2026 20:28:12 +0100 Message-ID: <20261104-work-procfs-bugfixes-v2-50-021c84d852e0@kernel.org> In-Reply-To: <20261104-work-procfs-bugfixes-v2-0-021c84d852e0@kernel.org> References: <20261104-work-procfs-bugfixes-v2-0-021c84d852e0@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1874; i=brauner@kernel.org; h=from:subject:message-id; bh=RrDLfW/scZN49peKw6fM9m5dxManPY8dszrBpi62+JM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWS9buKUeD/54oKQeSXpZxZOuLHujuvOvQuDLBr9a+Q0/ fdzHMw27yhlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjIxk+MDF0xzMdUqudtc4xq io94MDlmc+iGj38/VuQy/ygRejLx7E1Ghg97a149/ZQ8UYb1fduSSTfDdZwEJovX7fM76eJtPX3 mTFYA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 proc_get_link() pins the entry with use_pde() and the delayed call unpins it. vfs_readlink() copies the link to userspace in between. So a page fault in that copy holds up remove_proc_entry() just like the copies of reads and writes do, and the callers hold locks while they wait. /proc/asound/ is removed with snd_card_mutex and info_mutex held when a card changes its id. The pin doesn't keep anything alive. proc_symlink() copies the target and pde_free() frees it with the entry, and the inode holds a reference to the entry. What the pin does is keep a removed symlink from being followed. So check ->in_use instead and drop the delayed call. That also takes an atomic pair off every traversal of /proc/net and /proc/mounts. Fixes: 7e0e953bb0cf ("procfs: fix race between symlink removals and traversals") Cc: stable@vger.kernel.org Signed-off-by: Christian Brauner (Amutable) --- fs/proc/inode.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 9933f03ab9fb..2d65f3c8ec03 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -629,19 +629,19 @@ static const struct file_operations proc_iter_file_ops_compat = { }; #endif -static void proc_put_link(void *p) -{ - unuse_pde(p); -} - static const char *proc_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *done) { struct proc_dir_entry *pde = PDE(inode); - if (!use_pde(pde)) + + /* + * No pin. The link lives with the entry, which the inode holds, and a + * reader could fault while vfs_readlink() copies it out. Just don't + * follow a removed one. + */ + if (unlikely(atomic_read(&pde->in_use) < 0)) return ERR_PTR(-EINVAL); - set_delayed_call(done, proc_put_link, pde); return pde->data; } -- 2.53.0