]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pidfs: handle FS_IOC32_GETVERSION in compat ioctl
authorLi Chen <me@linux.beauty>
Thu, 16 Jul 2026 05:28:20 +0000 (13:28 +0800)
committerChristian Brauner <brauner@kernel.org>
Wed, 22 Jul 2026 14:45:57 +0000 (16:45 +0200)
FS_IOC32_GETVERSION has a distinct compat command encoding. Passing it
through compat_ptr_ioctl() leaves pidfd_ioctl() unable to recognize the
otherwise architecture-independent inode generation query.

Translate the compat command to FS_IOC_GETVERSION before dispatching it
through the native pidfd ioctl implementation.

Signed-off-by: Li Chen <me@linux.beauty>
Link: https://patch.msgid.link/20260716052822.1034228-1-me@linux.beauty
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/pidfs.c

index 695215aa2a5856e85854ab2aa90137182ebb6ddb..d7fe9abdd6f19229f74fb5bf02709057fffe2f54 100644 (file)
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/anon_inodes.h>
+#include <linux/compat.h>
 #include <linux/exportfs.h>
 #include <linux/file.h>
 #include <linux/fs.h>
@@ -659,6 +660,17 @@ static long pidfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        return open_namespace(ns_common);
 }
 
+#ifdef CONFIG_COMPAT
+static long pidfd_compat_ioctl(struct file *file, unsigned int cmd,
+                              unsigned long arg)
+{
+       if (cmd == FS_IOC32_GETVERSION)
+               cmd = FS_IOC_GETVERSION;
+
+       return pidfd_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+}
+#endif
+
 static int pidfs_file_release(struct inode *inode, struct file *file)
 {
        struct pid *pid = inode->i_private;
@@ -686,7 +698,9 @@ static const struct file_operations pidfs_file_operations = {
        .show_fdinfo    = pidfd_show_fdinfo,
 #endif
        .unlocked_ioctl = pidfd_ioctl,
-       .compat_ioctl   = compat_ptr_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl   = pidfd_compat_ioctl,
+#endif
 };
 
 struct pid *pidfd_pid(const struct file *file)