From patchwork Fri Apr 21 15:21:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9693257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8A7956038D for ; Fri, 21 Apr 2017 17:38:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F1522865C for ; Fri, 21 Apr 2017 17:38:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7409F28662; Fri, 21 Apr 2017 17:38:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 125FA2865C for ; Fri, 21 Apr 2017 17:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162286AbdDURHg (ORCPT ); Fri, 21 Apr 2017 13:07:36 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:43665 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162276AbdDURHc (ORCPT ); Fri, 21 Apr 2017 13:07:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xyM8e8vF0nheyrE0dTm6U0d/aGc8x+farKvlx9Eq4Q8=; b=TyzrpXWt+XBwpIIrYNFRwKCi2 8ebt1uYrXCwd6eSO8w/I5yLu6lAc74vl0ZXsy2bsmgEB6mOIisGUfKd4CApJTY4oMHaDMptL8HddU VnqXM5FoS2019tWhZwqVAmZBjbTtOEXXNDfjMaGi6nM6zHDp6QgdeVlZHJe9OuzZW4/wfV6wiKJc4 wCyN7nu+6iWBkUMh/AB9hqPFeCeTfXNlIH76cmkUaNJWlJ0gsz/HZjqnGceWJzKx2qluha6StDsmC H0gcYLPaGzMmtqc9dOCKOpk/y219tDR/Ks3Yb8uo8AxqaACwGB00F/EvqcLjwYYjWk7ewQfE3cJr1 VbZ2gBdhg==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1d1aNQ-0005VE-4q for linux-xfs@vger.kernel.org; Fri, 21 Apr 2017 15:21:40 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 4/6] xfs: fix __user annotations for xfs_ioc_getfsmap Date: Fri, 21 Apr 2017 17:21:21 +0200 Message-Id: <20170421152123.11316-5-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170421152123.11316-1-hch@lst.de> References: <20170421152123.11316-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Darrick J. Wong --- 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; __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; }