Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

autofs: use AUTOFS_DEV_IOCTL_SIZE

Use a macro which defines misc-dev ioctl parameter size (excluding a path
beyond &path[0]) since it's been used to initialize and copy this
structure ever since it first appeared in 8d7b48e0 in 2008.

(or simply get rid of this if this is just unnecessary abstraction when
all it needs is sizeof(struct autofs_dev_ioctl))

Edit: raven@themaw.net
That's a good point but I'd prefer to keep the macro define.
End edit: raven@themaw.net

Link: http://lkml.kernel.org/r/150285068577.4670.2599968823770600622.stgit@pluto.themaw.net
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Tomohiro Kusumi and committed by
Linus Torvalds
718b303b ed837d09

+7 -7
+7 -7
fs/autofs4/dev-ioctl.c
··· 97 97 { 98 98 struct autofs_dev_ioctl tmp, *res; 99 99 100 - if (copy_from_user(&tmp, in, sizeof(tmp))) 100 + if (copy_from_user(&tmp, in, AUTOFS_DEV_IOCTL_SIZE)) 101 101 return ERR_PTR(-EFAULT); 102 102 103 - if (tmp.size < sizeof(tmp)) 103 + if (tmp.size < AUTOFS_DEV_IOCTL_SIZE) 104 104 return ERR_PTR(-EINVAL); 105 105 106 - if (tmp.size > (PATH_MAX + sizeof(tmp))) 106 + if (tmp.size > AUTOFS_DEV_IOCTL_SIZE + PATH_MAX) 107 107 return ERR_PTR(-ENAMETOOLONG); 108 108 109 109 res = memdup_user(in, tmp.size); ··· 133 133 goto out; 134 134 } 135 135 136 - if (param->size > sizeof(*param)) { 137 - err = invalid_str(param->path, param->size - sizeof(*param)); 136 + if (param->size > AUTOFS_DEV_IOCTL_SIZE) { 137 + err = invalid_str(param->path, param->size - AUTOFS_DEV_IOCTL_SIZE); 138 138 if (err) { 139 139 pr_warn( 140 140 "path string terminator missing for cmd(0x%08x)\n", ··· 451 451 dev_t devid; 452 452 int err = -ENOENT; 453 453 454 - if (param->size <= sizeof(*param)) { 454 + if (param->size <= AUTOFS_DEV_IOCTL_SIZE) { 455 455 err = -EINVAL; 456 456 goto out; 457 457 } ··· 539 539 unsigned int devid, magic; 540 540 int err = -ENOENT; 541 541 542 - if (param->size <= sizeof(*param)) { 542 + if (param->size <= AUTOFS_DEV_IOCTL_SIZE) { 543 543 err = -EINVAL; 544 544 goto out; 545 545 }