diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2017-04-03 15:17:57 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2017-04-03 15:18:16 -0700 |
commit | be6324c00c4d1e0e665f03ed1fc18863a88da119 (patch) | |
tree | 276214b108e95e5bec99e26e7087c384b8f590d2 /fs/xfs | |
parent | 422e5b53ed83dd71c1eac276c6ec7f7c6e81ce8d (diff) | |
download | op-kernel-dev-be6324c00c4d1e0e665f03ed1fc18863a88da119.zip op-kernel-dev-be6324c00c4d1e0e665f03ed1fc18863a88da119.tar.gz |
xfs: fix over-copying of getbmap parameters from userspace
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>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_ioctl.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 2fd7fdf..6d30b06 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -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) |