Skip to content

Commit 1d0cff7

Browse files
FirstLoveLifebrauner
authored andcommitted
pidfs: handle FS_IOC32_GETVERSION in compat ioctl
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>
1 parent a1e0eb8 commit 1d0cff7

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

fs/pidfs.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/anon_inodes.h>
3+
#include <linux/compat.h>
34
#include <linux/exportfs.h>
45
#include <linux/file.h>
56
#include <linux/fs.h>
@@ -659,6 +660,17 @@ static long pidfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
659660
return open_namespace(ns_common);
660661
}
661662

663+
#ifdef CONFIG_COMPAT
664+
static long pidfd_compat_ioctl(struct file *file, unsigned int cmd,
665+
unsigned long arg)
666+
{
667+
if (cmd == FS_IOC32_GETVERSION)
668+
cmd = FS_IOC_GETVERSION;
669+
670+
return pidfd_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
671+
}
672+
#endif
673+
662674
static int pidfs_file_release(struct inode *inode, struct file *file)
663675
{
664676
struct pid *pid = inode->i_private;
@@ -686,7 +698,9 @@ static const struct file_operations pidfs_file_operations = {
686698
.show_fdinfo = pidfd_show_fdinfo,
687699
#endif
688700
.unlocked_ioctl = pidfd_ioctl,
689-
.compat_ioctl = compat_ptr_ioctl,
701+
#ifdef CONFIG_COMPAT
702+
.compat_ioctl = pidfd_compat_ioctl,
703+
#endif
690704
};
691705

692706
struct pid *pidfd_pid(const struct file *file)

0 commit comments

Comments
 (0)