Skip to content

Commit

Permalink
xfs: fix over-copying of getbmap parameters from userspace
Browse files Browse the repository at this point in the history
commit be6324c upstream.

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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
djwong authored and gregkh committed Jun 7, 2017
1 parent c2ad2dc commit de417ea
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/xfs/xfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1542,10 +1542,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)
Expand Down

0 comments on commit de417ea

Please sign in to comment.