All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	 linux-fsdevel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	 Aleksa Sarai <cyphar@cyphar.com>,
	Christian Brauner <brauner@kernel.org>
Subject: [PATCH RFC 3/6] proc: add proc_splice_unmountable()
Date: Tue, 06 Aug 2024 18:02:29 +0200	[thread overview]
Message-ID: <20240806-work-procfs-v1-3-fb04e1d09f0c@kernel.org> (raw)
In-Reply-To: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org>

Add a tiny procfs helper to splice a dentry that cannot be mounted upon.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/proc/internal.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index a8a8576d8592..9e3f25e4c188 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -349,3 +349,16 @@ static inline void pde_force_lookup(struct proc_dir_entry *pde)
 	/* /proc/net/ entries can be changed under us by setns(CLONE_NEWNET) */
 	pde->proc_dops = &proc_net_dentry_ops;
 }
+
+/*
+ * Add a new procfs dentry that can't serve as a mountpoint. That should
+ * encompass anything that is ephemeral and can just disappear while the
+ * process is still around.
+ */
+static inline struct dentry *proc_splice_unmountable(struct inode *inode,
+		struct dentry *dentry, const struct dentry_operations *d_ops)
+{
+	d_set_d_op(dentry, d_ops);
+	dont_mount(dentry);
+	return d_splice_alias(inode, dentry);
+}

-- 
2.43.0


  parent reply	other threads:[~2024-08-06 16:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-06 16:02 [PATCH RFC 0/6] proc: restrict overmounting of ephemeral entities Christian Brauner
2025-09-30  8:53 ` Petr Vorel
2024-08-06 16:02 ` [PATCH RFC 1/6] proc: proc_readfd() -> proc_fd_iterate_shared() Christian Brauner
2024-08-06 17:06   ` Linus Torvalds
2024-08-06 16:02 ` [PATCH RFC 2/6] proc: proc_readfdinfo() -> proc_fdinfo_iterate_shared() Christian Brauner
2024-08-06 16:02 ` Christian Brauner [this message]
2024-08-06 16:02 ` [PATCH RFC 4/6] proc: block mounting on top of /proc/<pid>/map_files/* Christian Brauner
2024-08-06 16:02 ` [PATCH RFC 5/6] proc: block mounting on top of /proc/<pid>/fd/* Christian Brauner
2024-08-06 16:02 ` [PATCH RFC 6/6] proc: block mounting on top of /proc/<pid>/fdinfo/* Christian Brauner
2024-08-07 14:33 ` [PATCH RFC 0/6] proc: restrict overmounting of ephemeral entities Josef Bacik
2025-09-30 15:51 ` Aleksa Sarai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240806-work-procfs-v1-3-fb04e1d09f0c@kernel.org \
    --to=brauner@kernel.org \
    --cc=cyphar@cyphar.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.