diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2017-04-03 15:17:57 -0700 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2017-06-25 00:25:36 -0400 |
commit | 17d031b4add771e425ce90b0b1c4f315a2b04a01 (patch) | |
tree | e77d089f642aada9799cbf5478bb3f29b09e1b76 /fs | |
parent | 74d27999c51e353fd0482c6750f98a7d3af2703d (diff) |
xfs: fix over-copying of getbmap parameters from userspace
[ Upstream commit be6324c00c4d1e0e665f03ed1fc18863a88da119 ]
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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Diffstat (limited to 'fs')
-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 82e49109d0b6..e69a0899bc05 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1368,10 +1368,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) |