public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Nick Bowler <nbowler@draconx.ca>
Cc: linux-xfs@vger.kernel.org, Brian Foster <bfoster@redhat.com>,
	Dave Chinner <david@fromorbit.com>
Subject: Re: [RFC PATCH v2 3/3] xfs: Fix x32 ioctls when cmd numbers differ from ia32.
Date: Mon, 17 Dec 2018 10:18:32 -0800	[thread overview]
Message-ID: <20181217181832.GK24487@magnolia> (raw)
In-Reply-To: <20181215012259.28358-4-nbowler@draconx.ca>

On Fri, Dec 14, 2018 at 08:22:59PM -0500, Nick Bowler wrote:
> Several ioctl structs change size between native 32-bit (ia32) and x32
> applications, because x32 follows the native 64-bit (amd64) integer
> alignment rules and uses 64-bit time_t.  In these instances, the ioctl
> number changes so userspace simply gets -ENOTTY.  This scenario can be
> handled by simply adding more cases.
> 
> Looking at the different ioctls implemented here:
> 
> - All the ones marked 'No size or alignment issue on any arch' should
>   presumably all be fine.
> 
> - All the ones under BROKEN_X86_ALIGNMENT are different under integer
>   alignment rules.  Since x32 matches amd64 here, we just need both
>   sets of cases handled.
> 
> - XFS_IOC_SWAPEXT has both integer alignment differences and time_t
>   differences.  Since x32 matches amd64 here, we need to add a case
>   which calls the native implementation.
> 
> - The remaining ioctls have neither 64-bit integers nor time_t, so
>   x32 matches ia32 here and no change is required at this level.  The
>   bulkstat ioctl implementations have some pointer chasing which is
>   handled separately.
> 
> Signed-off-by: Nick Bowler <nbowler@draconx.ca>

Looks mostly ok to me, provided they don't drop x32 this release.

(It doesn't sound to me like that's going to happen any time soon...)

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

(Will try to test all this... /me flexes his cross-arch muscles...)

--D

> ---
>  fs/xfs/xfs_ioctl32.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
> index 1cdc75dca779..bd9ffad0f65e 100644
> --- a/fs/xfs/xfs_ioctl32.c
> +++ b/fs/xfs/xfs_ioctl32.c
> @@ -579,8 +579,12 @@ xfs_file_compat_ioctl(
>  	case FS_IOC_GETFSMAP:
>  	case XFS_IOC_SCRUB_METADATA:
>  		return xfs_file_ioctl(filp, cmd, p);
> -#ifndef BROKEN_X86_ALIGNMENT
> -	/* These are handled fine if no alignment issues */
> +#if !defined(BROKEN_X86_ALIGNMENT) || defined(CONFIG_X86_X32)
> +	/*
> +	 * These are handled fine if no alignment issues.  To support x32
> +	 * which uses native 64-bit alignment we must emit these cases in
> +	 * addition to the ia-32 compat set below.
> +	 */
>  	case XFS_IOC_ALLOCSP:
>  	case XFS_IOC_FREESP:
>  	case XFS_IOC_RESVSP:
> @@ -593,8 +597,16 @@ xfs_file_compat_ioctl(
>  	case XFS_IOC_FSGROWFSDATA:
>  	case XFS_IOC_FSGROWFSRT:
>  	case XFS_IOC_ZERO_RANGE:
> +#ifdef CONFIG_X86_X32
> +	/*
> +	 * x32 special: this gets a different cmd number from the ia-32 compat
> +	 * case below; the associated data will match native 64-bit alignment.
> +	 */
> +	case XFS_IOC_SWAPEXT:
> +#endif
>  		return xfs_file_ioctl(filp, cmd, p);
> -#else
> +#endif
> +#if defined(BROKEN_X86_ALIGNMENT)
>  	case XFS_IOC_ALLOCSP_32:
>  	case XFS_IOC_FREESP_32:
>  	case XFS_IOC_ALLOCSP64_32:
> -- 
> 2.16.1
> 

  reply	other threads:[~2018-12-17 18:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-15  1:22 [RFC PATCH v2 0/3] Fixing xfs ioctls on x32 Nick Bowler
2018-12-15  1:22 ` [RFC PATCH v2 1/3] xfs: Align compat attrlist_by_handle with native implementation Nick Bowler
2018-12-17 17:34   ` Darrick J. Wong
2018-12-15  1:22 ` [RFC PATCH v2 2/3] xfs: Fix bulkstat compat ioctls on x32 userspace Nick Bowler
2018-12-17 17:40   ` Darrick J. Wong
2018-12-17 20:06     ` Nick Bowler
2018-12-17 20:09       ` Darrick J. Wong
2018-12-15  1:22 ` [RFC PATCH v2 3/3] xfs: Fix x32 ioctls when cmd numbers differ from ia32 Nick Bowler
2018-12-17 18:18   ` Darrick J. Wong [this message]
2018-12-18  1:24 ` [RFC PATCH v2 0/3] Fixing xfs ioctls on x32 Nick Bowler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181217181832.GK24487@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=bfoster@redhat.com \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=nbowler@draconx.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox