Skip to content

Commit

Permalink
autofs4 copy_dev_ioctl(): keep the value of ->size we'd used for allo…
Browse files Browse the repository at this point in the history
…cation

X-Coverup: just ask spender
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Feb 22, 2015
1 parent 7e0e953 commit 0a28096
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/autofs4/dev-ioctl.c
Expand Up @@ -95,7 +95,7 @@ static int check_dev_ioctl_version(int cmd, struct autofs_dev_ioctl *param)
*/
static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *in)
{
struct autofs_dev_ioctl tmp;
struct autofs_dev_ioctl tmp, *res;

if (copy_from_user(&tmp, in, sizeof(tmp)))
return ERR_PTR(-EFAULT);
Expand All @@ -106,7 +106,11 @@ static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *i
if (tmp.size > (PATH_MAX + sizeof(tmp)))
return ERR_PTR(-ENAMETOOLONG);

return memdup_user(in, tmp.size);
res = memdup_user(in, tmp.size);
if (!IS_ERR(res))
res->size = tmp.size;

return res;
}

static inline void free_dev_ioctl(struct autofs_dev_ioctl *param)
Expand Down

0 comments on commit 0a28096

Please sign in to comment.