* [PATCH 2/5] autofs: non functional header inclusion cleanup
2017-08-16 2:31 [PATCH 1/5] autofs: remove unused AUTOFS_IOC_EXPIRE_DIRECT/INDIRECT Ian Kent
@ 2017-08-16 2:31 ` Ian Kent
2017-08-16 2:31 ` [PATCH 3/5] autofs: use AUTOFS_DEV_IOCTL_SIZE Ian Kent
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ian Kent @ 2017-08-16 2:31 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-fsdevel, Tomohiro Kusumi, autofs mailing list, Kernel Mailing List
From: Tomohiro Kusumi <tkusumi@tuxera.com>
Having header includes before any macro (without any dependency)
simply looks normal. No reason to have these macros in between.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
fs/autofs4/autofs_i.h | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index beef981aa54f..4737615f0eaa 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -11,10 +11,21 @@
#include <linux/auto_fs4.h>
#include <linux/auto_dev-ioctl.h>
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/time.h>
+#include <linux/string.h>
+#include <linux/wait.h>
+#include <linux/sched.h>
+#include <linux/mount.h>
+#include <linux/namei.h>
+#include <linux/uaccess.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/completion.h>
+#include <asm/current.h>
/* This is the range of ioctl() numbers we claim as ours */
#define AUTOFS_IOC_FIRST AUTOFS_IOC_READY
@@ -24,17 +35,6 @@
#define AUTOFS_DEV_IOCTL_IOC_COUNT \
(AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD - AUTOFS_DEV_IOCTL_VERSION_CMD)
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/time.h>
-#include <linux/string.h>
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/mount.h>
-#include <linux/namei.h>
-#include <asm/current.h>
-#include <linux/uaccess.h>
-
#ifdef pr_fmt
#undef pr_fmt
#endif
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/5] autofs: use AUTOFS_DEV_IOCTL_SIZE
2017-08-16 2:31 [PATCH 1/5] autofs: remove unused AUTOFS_IOC_EXPIRE_DIRECT/INDIRECT Ian Kent
2017-08-16 2:31 ` [PATCH 2/5] autofs: non functional header inclusion cleanup Ian Kent
@ 2017-08-16 2:31 ` Ian Kent
2017-08-16 2:31 ` [PATCH 4/5] autofs: drop wrong comment Ian Kent
2017-08-16 2:31 ` [PATCH 5/5] autofs: use unsigned int/long instead of uint/ulong for ioctl args Ian Kent
3 siblings, 0 replies; 5+ messages in thread
From: Ian Kent @ 2017-08-16 2:31 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-fsdevel, Tomohiro Kusumi, autofs mailing list, Kernel Mailing List
From: Tomohiro Kusumi <tkusumi@tuxera.com>
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: imk
That's a good point but I'd prefer to keep the macro define.
End edit: imk
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
fs/autofs4/dev-ioctl.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index ea8b3a1cddd2..b8b66d55266d 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -97,13 +97,13 @@ static struct autofs_dev_ioctl *
{
struct autofs_dev_ioctl tmp, *res;
- if (copy_from_user(&tmp, in, sizeof(tmp)))
+ if (copy_from_user(&tmp, in, AUTOFS_DEV_IOCTL_SIZE))
return ERR_PTR(-EFAULT);
- if (tmp.size < sizeof(tmp))
+ if (tmp.size < AUTOFS_DEV_IOCTL_SIZE)
return ERR_PTR(-EINVAL);
- if (tmp.size > (PATH_MAX + sizeof(tmp)))
+ if (tmp.size > AUTOFS_DEV_IOCTL_SIZE + PATH_MAX)
return ERR_PTR(-ENAMETOOLONG);
res = memdup_user(in, tmp.size);
@@ -133,8 +133,8 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
goto out;
}
- if (param->size > sizeof(*param)) {
- err = invalid_str(param->path, param->size - sizeof(*param));
+ if (param->size > AUTOFS_DEV_IOCTL_SIZE) {
+ err = invalid_str(param->path, param->size - AUTOFS_DEV_IOCTL_SIZE);
if (err) {
pr_warn(
"path string terminator missing for cmd(0x%08x)\n",
@@ -451,7 +451,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
dev_t devid;
int err = -ENOENT;
- if (param->size <= sizeof(*param)) {
+ if (param->size <= AUTOFS_DEV_IOCTL_SIZE) {
err = -EINVAL;
goto out;
}
@@ -539,7 +539,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
unsigned int devid, magic;
int err = -ENOENT;
- if (param->size <= sizeof(*param)) {
+ if (param->size <= AUTOFS_DEV_IOCTL_SIZE) {
err = -EINVAL;
goto out;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/5] autofs: drop wrong comment
2017-08-16 2:31 [PATCH 1/5] autofs: remove unused AUTOFS_IOC_EXPIRE_DIRECT/INDIRECT Ian Kent
2017-08-16 2:31 ` [PATCH 2/5] autofs: non functional header inclusion cleanup Ian Kent
2017-08-16 2:31 ` [PATCH 3/5] autofs: use AUTOFS_DEV_IOCTL_SIZE Ian Kent
@ 2017-08-16 2:31 ` Ian Kent
2017-08-16 2:31 ` [PATCH 5/5] autofs: use unsigned int/long instead of uint/ulong for ioctl args Ian Kent
3 siblings, 0 replies; 5+ messages in thread
From: Ian Kent @ 2017-08-16 2:31 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-fsdevel, Tomohiro Kusumi, autofs mailing list, Kernel Mailing List
From: Tomohiro Kusumi <tkusumi@tuxera.com>
This comment was correct when it was added in 8d7b48e0 in 2008,
but not after 4e44b685 in 2009 which introduced find_autofs_mount().
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
fs/autofs4/dev-ioctl.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index b8b66d55266d..a990c9d0f893 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -258,11 +258,6 @@ static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid)
if (err)
goto out;
- /*
- * Find autofs super block that has the device number
- * corresponding to the autofs fs we want to open.
- */
-
filp = dentry_open(&path, O_RDONLY, current_cred());
path_put(&path);
if (IS_ERR(filp)) {
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5/5] autofs: use unsigned int/long instead of uint/ulong for ioctl args
2017-08-16 2:31 [PATCH 1/5] autofs: remove unused AUTOFS_IOC_EXPIRE_DIRECT/INDIRECT Ian Kent
` (2 preceding siblings ...)
2017-08-16 2:31 ` [PATCH 4/5] autofs: drop wrong comment Ian Kent
@ 2017-08-16 2:31 ` Ian Kent
3 siblings, 0 replies; 5+ messages in thread
From: Ian Kent @ 2017-08-16 2:31 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-fsdevel, Tomohiro Kusumi, autofs mailing list, Kernel Mailing List
From: Tomohiro Kusumi <tkusumi@tuxera.com>
The standard types unsigned int and unsigned long should be used for
.compat_ioctl. autofs is the only fs using uing/ulong for this, and
these are even the only uint/ulong in the entire autofs code.
Drop unneeded long cast in return value of autofs_dev_ioctl_compat().
It's already long.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
fs/autofs4/dev-ioctl.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index a990c9d0f893..b7c816f39404 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -93,7 +93,7 @@ static int check_dev_ioctl_version(int cmd, struct autofs_dev_ioctl *param)
* at the end of the struct.
*/
static struct autofs_dev_ioctl *
- copy_dev_ioctl(struct autofs_dev_ioctl __user *in)
+copy_dev_ioctl(struct autofs_dev_ioctl __user *in)
{
struct autofs_dev_ioctl tmp, *res;
@@ -705,7 +705,8 @@ static int _autofs_dev_ioctl(unsigned int command,
return err;
}
-static long autofs_dev_ioctl(struct file *file, uint command, ulong u)
+static long autofs_dev_ioctl(struct file *file, unsigned int command,
+ unsigned long u)
{
int err;
@@ -714,9 +715,10 @@ static long autofs_dev_ioctl(struct file *file, uint command, ulong u)
}
#ifdef CONFIG_COMPAT
-static long autofs_dev_ioctl_compat(struct file *file, uint command, ulong u)
+static long autofs_dev_ioctl_compat(struct file *file, unsigned int command,
+ unsigned long u)
{
- return (long) autofs_dev_ioctl(file, command, (ulong) compat_ptr(u));
+ return autofs_dev_ioctl(file, command, (unsigned long) compat_ptr(u));
}
#else
#define autofs_dev_ioctl_compat NULL
^ permalink raw reply related [flat|nested] 5+ messages in thread