Article View: linux.kernel.netdev
Article #11300[PATCH RESEND v2 50/51] proc: don't pin a symlink's entry while readlink() copies it out
From: Christian Brauner
Date: Wed, 04 Nov 2026 19:28
Date: Wed, 04 Nov 2026 19:28
56 lines
11940 bytes
11940 bytes
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/<id> 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) <brauner@kernel.org>
---
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
Technical Details
Message-ID:
<20261104-work-procfs-bugfixes-v2-50-021c84d852e0@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356776-linux-kernel-netdev=dewy.ruReferences:
<20261104-work-procfs-bugfixes-v2-0-021c84d852e0@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356776-linux-kernel-netdev=dewy.ru From: brauner@kernel.org (Christian Brauner) Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <20261104-work-procfs-bugfixes-v2-50-021c84d852e0@kernel.org> References: <20261104-work-procfs-bugfixes-v2-0-021c84d852e0@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3496071"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:7lHCY1FvorMiffYSdvxg7orkQJw= sha256:oui8Cunzc6xlywUt5hQfcPs8BxhL3WYxg27S9U47wAY= sha1:vRHh8hrkcFW1o/gOpQ0qV/GKrTY= sha256:a+KDFuplhOKvXwn4u1f7en6Cld9p9UAIrF2i12JHDJE= 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 01E52112DA1; Thu, 5 Nov 2026 00:51:09 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.301 X-Spam-Status: No, score=-2.301 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org 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 nyoQVu1g8MQo; Thu, 5 Nov 2026 00:51:06 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-356776-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id CB95A112CF7; Thu, 5 Nov 2026 00:50:57 +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 146D9106B1E; Wed, 4 Nov 2026 19:47:10 +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=1793820508; b=aXdr1rpGQmYBJWpgA9s0VrJgjPIdLJm5d3P8NmscK7Ip548uG+X+ryyO2ehvNuH7ihFd 9Jrd/gzcIfLFMaZuipHeOToSGd1CIuWtGG/jC3t/P7AQ07LmXp7cecRUke1sBpbgpOvxa qHzQs4G+ZW5BWK628wbVCPYy6Jvp2QyKL8bIM/Brb2bKRZYktDxlMCOEfyJUnb1Pr+upf jpfXGe5psEB1FzxILK8q3BxjBG8UMIP0xoxjF+uYNnZNx0/xon+0Uq2P+XOsk/RlkHyXN ExIvEdxMOiJ2tGQAq56ylJsaRd3lMEjvat6o6ZFaR4XvTJrH45v8Y/7QjCg9/dyc7nw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820508; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:In-Reply-To:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:X-Mailer:X-Developer-Signature: X-Developer-Key:Content-Transfer-Encoding; bh=gGh9qQAToZE5wrWgcgjg72Buy8fnK2LgswQGjbfg87A=; b=LQOBIAGP6UI7OzKo/Mgp18xlkeuIeNbtL1fhja63m8m2YHaggTq1WZvCFTMRmphUjvQ1 KIbCqVwib9bkCf3Fkv5CWMNRAKLo+XyYlo9uizaAR8D27zzTWsUi2KbdTjmOPjHxOWh+k 9AkB+5SszXv0IgugzUaq0s/KTXeG9eJgLBXfKU6296f9a9OKU2v/MCJG3dsAWFdhvlCbv XZyIoCV2h1aIl/wPmisCFuaVuOV5R9DZighnSFOh30IMvngOMvRWlszfCMpORvyUzkI+1 VgKeifaCPDT2KUwdy35vZFP5/GeNqdiqdmK+5gdQySG23x6rREv1Xum12YKX34zjQng== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=byXXsxYw; 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 F40976074FA0; Wed, 4 Nov 2026 19:28:27 +0000 (UTC) X-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 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793820507; b=RWd67/pcnxjPNymrX+/yMKmifJIcyM4e+KPE4C5MrXv4skWy/NXeJfqEaMgQDmRhddks aFjmSYxTwh4+hPg7RItz7D1VHix981YXzNnFwd4jg8M69Jylde9CQ7bhV7NxNdQroJUWP CtKy4inFdYt8UrNUbllJpCwoceK1dujjK6cXLRpo3qov+e2PTSuwfULj0YeVsMF157Xbp GCO080VdJYgwldjSU5/kZROFhaA+I/oD/JVI2GL22c4yV1fvHsXrdtX7QWLz02bmXDU1/ NnLSx0kVhs4npQOnajLwLh1EPAjVvvK5w8DlqYMEcyDgTLgcZSfRSfNGOljrS6bG82w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793820507; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: In-Reply-To:References:MIME-Version:Content-Type:X-Mailer: X-Developer-Signature:X-Developer-Key:Content-Transfer-Encoding; bh=gGh9qQAToZE5wrWgcgjg72Buy8fnK2LgswQGjbfg87A=; b=Sm/fwv2gIGgWoL/I3l2M0Kmj/UnTX7+KS0mW+B82QMeQNZ+qcPsqK0e7dlyO0+aHFfw+ z+GuHAJJsS1ESiTHeZfOmpi6e+FQA+bfN8dVglJ9WKykHXhj+muY4oyM5sobj/afkePrt nMvPY5V0ZGWg6PDTOEmQ8t4ErY7cndRxjfQ1TyHR/IxDwi3SD44e4kJK3H0Ep/Oss/xXU c1sw0rTzJFDPkzhhaEK5M+MTOPsj6f72A0ji+113+0RCzvPkzBd7d8yIRu3DRkMZRAWQs 17KeD3kLz0e8vuQyepx67k493HTH8dn4MGabPYToi4yOSQscmqE8MWt9XFxx3yf2bVw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=byXXsxYw; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (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 A1ED7606AB2B; Wed, 4 Nov 2026 19:28:26 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F5B61F00A02; Wed, 4 Nov 2026 19:28:14 +0000 (UTC) X-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== X-Cc: Linus Torvalds <torvalds@linux-foundation.org>, Jann Horn <jannh@google.com>, Josef Bacik <josef@toxicpanda.com>, Chris Mason <mason@kernel.org>, Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>, Eric Dumazet <edumazet@kernel.org>, Thomas Gleixner <tglx@kernel.org>, Al Viro <viro@zeniv.linux.org.uk>, Jonathan Corbet <corbet@lwn.net>, Christoph Hellwig <hch@lst.de>, Greg Kroah-Hartman <gregkh@suse.de>, Joel Granados <joel.granados@kernel.org>, Kees Cook <kees@kernel.org>, Jan Kara <jack@suse.cz>, Jan Kara <jack@suse.com>, 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 <tiwai@suse.de>, 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)" <brauner@kernel.org>, Chuck Lever <cel@kernel.org>, stable@vger.kernel.org X-In-Reply-To: <20261104-work-procfs-bugfixes-v2-0-021c84d852e0@kernel.org> 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 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