aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4/dev-ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/autofs4/dev-ioctl.c')
-rw-r--r--fs/autofs4/dev-ioctl.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index ac7d921ed984..c7fcc7438843 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -72,13 +72,13 @@ static int check_dev_ioctl_version(int cmd, struct autofs_dev_ioctl *param)
72{ 72{
73 int err = 0; 73 int err = 0;
74 74
75 if ((AUTOFS_DEV_IOCTL_VERSION_MAJOR != param->ver_major) || 75 if ((param->ver_major != AUTOFS_DEV_IOCTL_VERSION_MAJOR) ||
76 (AUTOFS_DEV_IOCTL_VERSION_MINOR < param->ver_minor)) { 76 (param->ver_minor > AUTOFS_DEV_IOCTL_VERSION_MINOR)) {
77 AUTOFS_WARN("ioctl control interface version mismatch: " 77 pr_warn("ioctl control interface version mismatch: "
78 "kernel(%u.%u), user(%u.%u), cmd(%d)", 78 "kernel(%u.%u), user(%u.%u), cmd(%d)\n",
79 AUTOFS_DEV_IOCTL_VERSION_MAJOR, 79 AUTOFS_DEV_IOCTL_VERSION_MAJOR,
80 AUTOFS_DEV_IOCTL_VERSION_MINOR, 80 AUTOFS_DEV_IOCTL_VERSION_MINOR,
81 param->ver_major, param->ver_minor, cmd); 81 param->ver_major, param->ver_minor, cmd);
82 err = -EINVAL; 82 err = -EINVAL;
83 } 83 }
84 84
@@ -93,7 +93,8 @@ static int check_dev_ioctl_version(int cmd, struct autofs_dev_ioctl *param)
93 * Copy parameter control struct, including a possible path allocated 93 * Copy parameter control struct, including a possible path allocated
94 * at the end of the struct. 94 * at the end of the struct.
95 */ 95 */
96static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *in) 96static struct autofs_dev_ioctl *
97 copy_dev_ioctl(struct autofs_dev_ioctl __user *in)
97{ 98{
98 struct autofs_dev_ioctl tmp, *res; 99 struct autofs_dev_ioctl tmp, *res;
99 100
@@ -116,7 +117,6 @@ static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *i
116static inline void free_dev_ioctl(struct autofs_dev_ioctl *param) 117static inline void free_dev_ioctl(struct autofs_dev_ioctl *param)
117{ 118{
118 kfree(param); 119 kfree(param);
119 return;
120} 120}
121 121
122/* 122/*
@@ -129,24 +129,24 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
129 129
130 err = check_dev_ioctl_version(cmd, param); 130 err = check_dev_ioctl_version(cmd, param);
131 if (err) { 131 if (err) {
132 AUTOFS_WARN("invalid device control module version " 132 pr_warn("invalid device control module version "
133 "supplied for cmd(0x%08x)", cmd); 133 "supplied for cmd(0x%08x)\n", cmd);
134 goto out; 134 goto out;
135 } 135 }
136 136
137 if (param->size > sizeof(*param)) { 137 if (param->size > sizeof(*param)) {
138 err = invalid_str(param->path, param->size - sizeof(*param)); 138 err = invalid_str(param->path, param->size - sizeof(*param));
139 if (err) { 139 if (err) {
140 AUTOFS_WARN( 140 pr_warn(
141 "path string terminator missing for cmd(0x%08x)", 141 "path string terminator missing for cmd(0x%08x)\n",
142 cmd); 142 cmd);
143 goto out; 143 goto out;
144 } 144 }
145 145
146 err = check_name(param->path); 146 err = check_name(param->path);
147 if (err) { 147 if (err) {
148 AUTOFS_WARN("invalid path supplied for cmd(0x%08x)", 148 pr_warn("invalid path supplied for cmd(0x%08x)\n",
149 cmd); 149 cmd);
150 goto out; 150 goto out;
151 } 151 }
152 } 152 }
@@ -197,7 +197,9 @@ static int find_autofs_mount(const char *pathname,
197 void *data) 197 void *data)
198{ 198{
199 struct path path; 199 struct path path;
200 int err = kern_path_mountpoint(AT_FDCWD, pathname, &path, 0); 200 int err;
201
202 err = kern_path_mountpoint(AT_FDCWD, pathname, &path, 0);
201 if (err) 203 if (err)
202 return err; 204 return err;
203 err = -ENOENT; 205 err = -ENOENT;
@@ -225,6 +227,7 @@ static int test_by_dev(struct path *path, void *p)
225static int test_by_type(struct path *path, void *p) 227static int test_by_type(struct path *path, void *p)
226{ 228{
227 struct autofs_info *ino = autofs4_dentry_ino(path->dentry); 229 struct autofs_info *ino = autofs4_dentry_ino(path->dentry);
230
228 return ino && ino->sbi->type & *(unsigned *)p; 231 return ino && ino->sbi->type & *(unsigned *)p;
229} 232}
230 233
@@ -370,7 +373,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
370 new_pid = get_task_pid(current, PIDTYPE_PGID); 373 new_pid = get_task_pid(current, PIDTYPE_PGID);
371 374
372 if (ns_of_pid(new_pid) != ns_of_pid(sbi->oz_pgrp)) { 375 if (ns_of_pid(new_pid) != ns_of_pid(sbi->oz_pgrp)) {
373 AUTOFS_WARN("Not allowed to change PID namespace"); 376 pr_warn("not allowed to change PID namespace\n");
374 err = -EINVAL; 377 err = -EINVAL;
375 goto out; 378 goto out;
376 } 379 }
@@ -456,8 +459,10 @@ static int autofs_dev_ioctl_requester(struct file *fp,
456 err = 0; 459 err = 0;
457 autofs4_expire_wait(path.dentry, 0); 460 autofs4_expire_wait(path.dentry, 0);
458 spin_lock(&sbi->fs_lock); 461 spin_lock(&sbi->fs_lock);
459 param->requester.uid = from_kuid_munged(current_user_ns(), ino->uid); 462 param->requester.uid =
460 param->requester.gid = from_kgid_munged(current_user_ns(), ino->gid); 463 from_kuid_munged(current_user_ns(), ino->uid);
464 param->requester.gid =
465 from_kgid_munged(current_user_ns(), ino->gid);
461 spin_unlock(&sbi->fs_lock); 466 spin_unlock(&sbi->fs_lock);
462 } 467 }
463 path_put(&path); 468 path_put(&path);
@@ -619,7 +624,8 @@ static ioctl_fn lookup_dev_ioctl(unsigned int cmd)
619} 624}
620 625
621/* ioctl dispatcher */ 626/* ioctl dispatcher */
622static int _autofs_dev_ioctl(unsigned int command, struct autofs_dev_ioctl __user *user) 627static int _autofs_dev_ioctl(unsigned int command,
628 struct autofs_dev_ioctl __user *user)
623{ 629{
624 struct autofs_dev_ioctl *param; 630 struct autofs_dev_ioctl *param;
625 struct file *fp; 631 struct file *fp;
@@ -655,7 +661,7 @@ static int _autofs_dev_ioctl(unsigned int command, struct autofs_dev_ioctl __use
655 661
656 fn = lookup_dev_ioctl(cmd); 662 fn = lookup_dev_ioctl(cmd);
657 if (!fn) { 663 if (!fn) {
658 AUTOFS_WARN("unknown command 0x%08x", command); 664 pr_warn("unknown command 0x%08x\n", command);
659 return -ENOTTY; 665 return -ENOTTY;
660 } 666 }
661 667
@@ -711,6 +717,7 @@ out:
711static long autofs_dev_ioctl(struct file *file, uint command, ulong u) 717static long autofs_dev_ioctl(struct file *file, uint command, ulong u)
712{ 718{
713 int err; 719 int err;
720
714 err = _autofs_dev_ioctl(command, (struct autofs_dev_ioctl __user *) u); 721 err = _autofs_dev_ioctl(command, (struct autofs_dev_ioctl __user *) u);
715 return (long) err; 722 return (long) err;
716} 723}
@@ -733,8 +740,8 @@ static const struct file_operations _dev_ioctl_fops = {
733 740
734static struct miscdevice _autofs_dev_ioctl_misc = { 741static struct miscdevice _autofs_dev_ioctl_misc = {
735 .minor = AUTOFS_MINOR, 742 .minor = AUTOFS_MINOR,
736 .name = AUTOFS_DEVICE_NAME, 743 .name = AUTOFS_DEVICE_NAME,
737 .fops = &_dev_ioctl_fops 744 .fops = &_dev_ioctl_fops
738}; 745};
739 746
740MODULE_ALIAS_MISCDEV(AUTOFS_MINOR); 747MODULE_ALIAS_MISCDEV(AUTOFS_MINOR);
@@ -747,7 +754,7 @@ int __init autofs_dev_ioctl_init(void)
747 754
748 r = misc_register(&_autofs_dev_ioctl_misc); 755 r = misc_register(&_autofs_dev_ioctl_misc);
749 if (r) { 756 if (r) {
750 AUTOFS_ERROR("misc_register failed for control device"); 757 pr_err("misc_register failed for control device\n");
751 return r; 758 return r;
752 } 759 }
753 760
@@ -757,6 +764,4 @@ int __init autofs_dev_ioctl_init(void)
757void autofs_dev_ioctl_exit(void) 764void autofs_dev_ioctl_exit(void)
758{ 765{
759 misc_deregister(&_autofs_dev_ioctl_misc); 766 misc_deregister(&_autofs_dev_ioctl_misc);
760 return;
761} 767}
762