Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d5d3fb3 authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Greg Kroah-Hartman
Browse files

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: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4c890b8c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1378,10 +1378,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)