autofs4: check dev ioctl size before allocating
Ian Kent
maintainerPATCH 1/1 autofs4: check dev ioctl size before allocating
From: Sasha Levin <[email protected]>
There wasn't any check of the size passed from userspace before trying to allocate the memory required.
This meant that userspace might request more space than allowed, triggering an OOM.
Signed-off-by Sasha Levin <[email protected]>
Signed-off-by Ian Kent <[email protected]>
--- fs/autofs4/dev-ioctl.c | 3 +++ 1 file changed, 3 insertions(+)
fs/autofs4/dev-ioctl.c +3 -0
@@ -103,6 +103,9 @@ static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *iif (tmp.size <sizeof (tmp))return ERR_PTR (-EINVAL ); +if (tmp.size > (PATH_MAX +sizeof (tmp))) +return ERR_PTR (-ENAMETOOLONG ); +return memdup_user (in, tmp.size); }