Commit be6324c0 authored by Darrick J. Wong's avatar Darrick J. Wong

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: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 422e5b53
...@@ -1543,10 +1543,11 @@ xfs_ioc_getbmap( ...@@ -1543,10 +1543,11 @@ xfs_ioc_getbmap(
unsigned int cmd, unsigned int cmd,
void __user *arg) void __user *arg)
{ {
struct getbmapx bmx; struct getbmapx bmx = { 0 };
int error; 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; return -EFAULT;
if (bmx.bmv_count < 2) if (bmx.bmv_count < 2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment