pidfs: handle FS_IOC32_GETVERSION in compat ioctl
PATCH 1/1 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.
--- fs/pidfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
fs/pidfs.c +15 -1
@@ -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)
Signature · 1 line
2.52.0
Quoted 8 lines · Li Chen
FS_IOC32_GETVERSIONhas a distinct compat command encoding. Passing it throughcompat_ptr_ioctl()leavespidfd_ioctl()unable to recognize the otherwise architecture-independent inode generation query.Translate the compat command to
FS_IOC_GETVERSIONbefore dispatching it through the native pidfd ioctl implementation.Signed-off-by Li Chen <[email protected]>
It's a bit sad we have to do this but you seem to be right. Feel free to add:
Quoted 47 lines
--- fs/pidfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)fs/pidfs.c +15
-1@@ -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)Signature · 1 line
2.52.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 1 line · Li Chen
pidfs: handle
FS_IOC32_GETVERSIONin compat ioctl
Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.fixes
[1/1] pidfs: handle FS_IOC32_GETVERSION in compat ioctl
https://git.kernel.org/vfs/vfs/c/d5eb51fc0b49