summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2026-07-29 15:03:14 +0200
committerCarlos Maiolino <cem@kernel.org>2026-09-07 07:51:51 +0200
commit31256907674fbb667fd56b401e057866609f212c (patch)
tree38fa41a4f7f83413a08f91c9346141fc8f092b35
parenta9a1dc9eaf2a1992e46a8c2d98c63b1105c3b20a (diff)
downloadlinux-next-31256907674fbb667fd56b401e057866609f212c.tar.gz
linux-next-31256907674fbb667fd56b401e057866609f212c.zip
xfs: split out the handlers for XFS_IOC_*_BY_HANDLE_32
Split out helpers for XFS_IOC_*_BY_HANDLE_32 to keep the stack variables out of xfs_file_compat_ioctl and to clean up the main compat ioctl handler flow. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r--fs/xfs/xfs_ioctl32.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index a6e3b35db6e2..688eb3300495 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -379,6 +379,43 @@ xfs_compat_handlereq_to_dentry(
compat_ptr(hreq->ihandle), hreq->ihandlen);
}
+static int
+xfs_compat_ioc_find_handle(
+ unsigned int cmd,
+ void __user *arg)
+{
+ struct xfs_fsop_handlereq hreq;
+
+ if (xfs_compat_handlereq_copyin(&hreq, arg))
+ return -EFAULT;
+ return xfs_find_handle(_NATIVE_IOC(cmd, struct xfs_fsop_handlereq),
+ &hreq);
+}
+
+static int
+xfs_compat_ioc_open_by_handle(
+ struct file *file,
+ void __user *arg)
+{
+ struct xfs_fsop_handlereq hreq;
+
+ if (xfs_compat_handlereq_copyin(&hreq, arg))
+ return -EFAULT;
+ return xfs_open_by_handle(file, &hreq);
+}
+
+static int
+xfs_compat_ioc_readlink_by_handle(
+ struct file *file,
+ void __user *arg)
+{
+ struct xfs_fsop_handlereq hreq;
+
+ if (xfs_compat_handlereq_copyin(&hreq, arg))
+ return -EFAULT;
+ return xfs_readlink_by_handle(file, &hreq);
+}
+
STATIC int
xfs_compat_attrlist_by_handle(
struct file *parfilp,
@@ -490,28 +527,12 @@ xfs_file_compat_ioctl(
return xfs_compat_ioc_fsbulkstat(filp, cmd, arg);
case XFS_IOC_FD_TO_HANDLE_32:
case XFS_IOC_PATH_TO_HANDLE_32:
- case XFS_IOC_PATH_TO_FSHANDLE_32: {
- struct xfs_fsop_handlereq hreq;
-
- if (xfs_compat_handlereq_copyin(&hreq, arg))
- return -EFAULT;
- cmd = _NATIVE_IOC(cmd, struct xfs_fsop_handlereq);
- return xfs_find_handle(cmd, &hreq);
- }
- case XFS_IOC_OPEN_BY_HANDLE_32: {
- struct xfs_fsop_handlereq hreq;
-
- if (xfs_compat_handlereq_copyin(&hreq, arg))
- return -EFAULT;
- return xfs_open_by_handle(filp, &hreq);
- }
- case XFS_IOC_READLINK_BY_HANDLE_32: {
- struct xfs_fsop_handlereq hreq;
-
- if (xfs_compat_handlereq_copyin(&hreq, arg))
- return -EFAULT;
- return xfs_readlink_by_handle(filp, &hreq);
- }
+ case XFS_IOC_PATH_TO_FSHANDLE_32:
+ return xfs_compat_ioc_find_handle(cmd, arg);
+ case XFS_IOC_OPEN_BY_HANDLE_32:
+ return xfs_compat_ioc_open_by_handle(filp, arg);
+ case XFS_IOC_READLINK_BY_HANDLE_32:
+ return xfs_compat_ioc_readlink_by_handle(filp, arg);
case XFS_IOC_ATTRLIST_BY_HANDLE_32:
return xfs_compat_attrlist_by_handle(filp, arg);
case XFS_IOC_ATTRMULTI_BY_HANDLE_32: