Skip to content

Commit 0ace12c

Browse files
djwonggregkh
authored andcommitted
xfs: fix over-copying of getbmap parameters from userspace
commit be6324c00c4d1e0e665f03ed1fc18863a88da119 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>
1 parent fe70562 commit 0ace12c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

fs/xfs/xfs_ioctl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,10 +1379,11 @@ xfs_ioc_getbmap(
13791379
unsigned int cmd,
13801380
void __user *arg)
13811381
{
1382-
struct getbmapx bmx;
1382+
struct getbmapx bmx = { 0 };
13831383
int error;
13841384

1385-
if (copy_from_user(&bmx, arg, sizeof(struct getbmapx)))
1385+
/* struct getbmap is a strict subset of struct getbmapx. */
1386+
if (copy_from_user(&bmx, arg, offsetof(struct getbmapx, bmv_iflags)))
13861387
return -EFAULT;
13871388

13881389
if (bmx.bmv_count < 2)

0 commit comments

Comments
 (0)