summaryrefslogtreecommitdiff
path: root/fs/pidfs.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2024-11-29 14:02:25 +0100
committerChristian Brauner <brauner@kernel.org>2024-12-14 12:40:40 +0100
commit230536ff6b06b199995687aa7fbf164970ebda85 (patch)
tree708d79442a8807c49c8e0cf06fae38ca17b778aa /fs/pidfs.c
parent03c212bf3fa86820baa5bcad75cfabb845166ccd (diff)
pidfs: support FS_IOC_GETVERSION
This will allow 32 bit userspace to detect when a given inode number has been recycled and also to construct a unique 64 bit identifier. Link: https://lore.kernel.org/r/20241129-work-pidfs-v2-3-61043d66fbce@kernel.org Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/pidfs.c')
-rw-r--r--fs/pidfs.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/pidfs.c b/fs/pidfs.c
index 71af820eafa5..8d62d900d20d 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -271,6 +271,14 @@ static long pidfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct ns_common *ns_common = NULL;
struct pid_namespace *pid_ns;
+ if (cmd == FS_IOC_GETVERSION) {
+ if (!arg)
+ return -EINVAL;
+
+ __u32 __user *argp = (__u32 __user *)arg;
+ return put_user(file_inode(file)->i_generation, argp);
+ }
+
task = get_pid_task(pid, PIDTYPE_PID);
if (!task)
return -ESRCH;