]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
xfs: fix over-copying of getbmap parameters from userspace
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 3 Apr 2017 22:17:57 +0000 (15:17 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Mon, 3 Apr 2017 22:18:16 +0000 (15:18 -0700)
In xfs_ioc_getbmap, we should only copy the fields of struct getbmap
from userspace, or else we end up copying random stack contents into the
kernel.  struct getbmap is a strict subset of getbmapx, so a partial
structure copy should work fine.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_ioctl.c

index 2fd7fdf5438f0be85220b9981bff09efce773079..6d30b06e79bcb4a7ec716a2000258fb65b706475 100644 (file)
@@ -1543,10 +1543,11 @@ xfs_ioc_getbmap(
        unsigned int            cmd,
        void                    __user *arg)
 {
-       struct getbmapx         bmx;
+       struct getbmapx         bmx = { 0 };
        int                     error;
 
-       if (copy_from_user(&bmx, arg, sizeof(struct getbmapx)))
+       /* struct getbmap is a strict subset of struct getbmapx. */
+       if (copy_from_user(&bmx, arg, offsetof(struct getbmapx, bmv_iflags)))
                return -EFAULT;
 
        if (bmx.bmv_count < 2)