xfs: Fix bulkstat compat ioctls on x32 userspace.
authorNick Bowler <nbowler@draconx.ca>
Mon, 17 Dec 2018 17:35:27 +0000 (09:35 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 18 Dec 2018 18:55:20 +0000 (10:55 -0800)
commit7ca860e3c1a74ad6bd8949364073ef1044cad758
tree1ca973be589423b562b186c0c3cb97e777d75df3
parentc456d64449efe37da50832b63d91652a85ea1d20
xfs: Fix bulkstat compat ioctls on x32 userspace.

The bulkstat family of ioctls are problematic on x32, because there is
a mixup of native 32-bit and 64-bit conventions.  The xfs_fsop_bulkreq
struct contains pointers and 32-bit integers so that matches the native
32-bit layout, and that means the ioctl implementation goes into the
regular compat path on x32.

However, the 'ubuffer' member of that struct in turn refers to either
struct xfs_inogrp or xfs_bstat (or an array of these).  On x32, those
structures match the native 64-bit layout.  The compat implementation
writes out the 32-bit version of these structures.  This is not the
expected format for x32 userspace, causing problems.

Fortunately the functions which actually output these xfs_inogrp and
xfs_bstat structures have an easy way to select which output format
is required, so we just need a little tweak to select the right format
on x32.

Signed-off-by: Nick Bowler <nbowler@draconx.ca>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_ioctl32.c