public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/6] xfs: fix __user annotations for xfs_ioc_getfsmap
Date: Fri, 21 Apr 2017 12:08:55 -0700	[thread overview]
Message-ID: <20170421190854.GI23371@birch.djwong.org> (raw)
In-Reply-To: <20170421152123.11316-5-hch@lst.de>

On Fri, Apr 21, 2017 at 05:21:21PM +0200, Christoph Hellwig wrote:
> By passing the whole fsmap_head structure and an index we can get the
> user point annotations right for the embedded variable sized array
> in struct fsmap_head.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_ioctl.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 0f8bed9a7e4c..b7db0b8f0657 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1614,7 +1614,8 @@ xfs_ioc_getbmapx(
>  
>  struct getfsmap_info {
>  	struct xfs_mount	*mp;
> -	struct fsmap __user	*data;
> +	struct fsmap_head __user *data;
> +	int			idx;

This ought to be unsigned int since fmh_entries is u32.  I'll fix
it when I commit the patch.

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

--D

>  	__u32			last_flags;
>  };
>  
> @@ -1628,17 +1629,17 @@ xfs_getfsmap_format(struct xfs_fsmap *xfm, void *priv)
>  
>  	info->last_flags = xfm->fmr_flags;
>  	xfs_fsmap_from_internal(&fm, xfm);
> -	if (copy_to_user(info->data, &fm, sizeof(struct fsmap)))
> +	if (copy_to_user(&info->data->fmh_recs[info->idx++], &fm,
> +			sizeof(struct fsmap)))
>  		return -EFAULT;
>  
> -	info->data++;
>  	return 0;
>  }
>  
>  STATIC int
>  xfs_ioc_getfsmap(
>  	struct xfs_inode	*ip,
> -	void			__user *arg)
> +	struct fsmap_head	__user *arg)
>  {
>  	struct getfsmap_info	info = { NULL };
>  	struct xfs_fsmap_head	xhead = {0};
> @@ -1664,7 +1665,7 @@ xfs_ioc_getfsmap(
>  	trace_xfs_getfsmap_high_key(ip->i_mount, &xhead.fmh_keys[1]);
>  
>  	info.mp = ip->i_mount;
> -	info.data = ((__force struct fsmap_head *)arg)->fmh_recs;
> +	info.data = arg;
>  	error = xfs_getfsmap(ip->i_mount, &xhead, xfs_getfsmap_format, &info);
>  	if (error == XFS_BTREE_QUERY_RANGE_ABORT) {
>  		error = 0;
> @@ -1674,10 +1675,9 @@ xfs_ioc_getfsmap(
>  
>  	/* If we didn't abort, set the "last" flag in the last fmx */
>  	if (!aborted && xhead.fmh_entries) {
> -		info.data--;
>  		info.last_flags |= FMR_OF_LAST;
> -		if (copy_to_user(&info.data->fmr_flags, &info.last_flags,
> -				sizeof(info.last_flags)))
> +		if (copy_to_user(&info.data->fmh_recs[info.idx - 1].fmr_flags,
> +				&info.last_flags, sizeof(info.last_flags)))
>  			return -EFAULT;
>  	}
>  
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-04-21 19:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-21 15:21 a few sparse inspired cleanups / fixes Christoph Hellwig
2017-04-21 15:21 ` [PATCH 1/6] xfs: use NULL instead of 0 to initialize a pointer in xfs_getfsmap Christoph Hellwig
2017-04-21 19:04   ` Darrick J. Wong
2017-04-21 15:21 ` [PATCH 2/6] xfs: use NULL instead of 0 to initialize a pointer in xfs_ioc_getfsmap Christoph Hellwig
2017-04-21 19:04   ` Darrick J. Wong
2017-04-21 15:21 ` [PATCH 3/6] xfs: corruption needs to respect endianess too! Christoph Hellwig
2017-04-21 19:05   ` Darrick J. Wong
2017-04-21 15:21 ` [PATCH 4/6] xfs: fix __user annotations for xfs_ioc_getfsmap Christoph Hellwig
2017-04-21 19:08   ` Darrick J. Wong [this message]
2017-04-21 15:21 ` [PATCH 5/6] xfs: don't use bool values in trace buffers Christoph Hellwig
2017-04-21 19:33   ` Darrick J. Wong
2017-04-23  7:38     ` Christoph Hellwig
2017-04-21 15:21 ` [PATCH 6/6] xfs: remove xfs_trans_ail_delete_bulk Christoph Hellwig
2017-04-21 19:35   ` Darrick J. Wong

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=20170421190854.GI23371@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    /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