linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] autofs - improve ioctl sbi checks
@ 2018-11-13  1:35 Ian Kent
  2018-11-13  1:36 ` [PATCH 2/6] autofs - fix possible inode leak in autofs_fill_super() Ian Kent
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Ian Kent @ 2018-11-13  1:35 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, autofs mailing list, Kernel Mailing List, linux-fsdevel

Al Viro made some suggestions to improve the implementation
of commit 0633da48f0 "fix autofs_sbi() does not check super
block type".

The check is unnessesary in all cases except for ioctl usage
so placing the check in the super block accessor function
adds a small overhead to the common case where it isn't
needed.

So it's sufficient to do this in the ioctl code only.

Also the check in the ioctl code is needlessly complex.

Signed-off-by: Ian Kent <raven@themaw.net>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
---
 fs/autofs/autofs_i.h  |    3 +--
 fs/autofs/dev-ioctl.c |   25 +++++++------------------
 fs/autofs/init.c      |    2 +-
 3 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index 9f9cadbfbd7a..c4301e33c027 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -126,8 +126,7 @@ struct autofs_sb_info {
 
 static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb)
 {
-	return sb->s_magic != AUTOFS_SUPER_MAGIC ?
-		NULL : (struct autofs_sb_info *)(sb->s_fs_info);
+	return (struct autofs_sb_info *)(sb->s_fs_info);
 }
 
 static inline struct autofs_info *autofs_dentry_ino(struct dentry *dentry)
diff --git a/fs/autofs/dev-ioctl.c b/fs/autofs/dev-ioctl.c
index 86eafda4a652..3de4f5e61caf 100644
--- a/fs/autofs/dev-ioctl.c
+++ b/fs/autofs/dev-ioctl.c
@@ -14,6 +14,8 @@
 
 #include "autofs_i.h"
 
+extern struct file_system_type autofs_fs_type;
+
 /*
  * This module implements an interface for routing autofs ioctl control
  * commands via a miscellaneous device file.
@@ -151,22 +153,6 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
 	return err;
 }
 
-/*
- * Get the autofs super block info struct from the file opened on
- * the autofs mount point.
- */
-static struct autofs_sb_info *autofs_dev_ioctl_sbi(struct file *f)
-{
-	struct autofs_sb_info *sbi = NULL;
-	struct inode *inode;
-
-	if (f) {
-		inode = file_inode(f);
-		sbi = autofs_sbi(inode->i_sb);
-	}
-	return sbi;
-}
-
 /* Return autofs dev ioctl version */
 static int autofs_dev_ioctl_version(struct file *fp,
 				    struct autofs_sb_info *sbi,
@@ -658,6 +644,8 @@ static int _autofs_dev_ioctl(unsigned int command,
 	if (cmd != AUTOFS_DEV_IOCTL_VERSION_CMD &&
 	    cmd != AUTOFS_DEV_IOCTL_OPENMOUNT_CMD &&
 	    cmd != AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD) {
+		struct super_block *sb;
+
 		fp = fget(param->ioctlfd);
 		if (!fp) {
 			if (cmd == AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD)
@@ -666,12 +654,13 @@ static int _autofs_dev_ioctl(unsigned int command,
 			goto out;
 		}
 
-		sbi = autofs_dev_ioctl_sbi(fp);
-		if (!sbi || sbi->magic != AUTOFS_SBI_MAGIC) {
+		sb = file_inode(fp)->i_sb;
+		if (sb->s_type != &autofs_fs_type) {
 			err = -EINVAL;
 			fput(fp);
 			goto out;
 		}
+		sbi = autofs_sbi(sb);
 
 		/*
 		 * Admin needs to be able to set the mount catatonic in
diff --git a/fs/autofs/init.c b/fs/autofs/init.c
index 79ae07d9592f..c0c1db2cc6ea 100644
--- a/fs/autofs/init.c
+++ b/fs/autofs/init.c
@@ -16,7 +16,7 @@ static struct dentry *autofs_mount(struct file_system_type *fs_type,
 	return mount_nodev(fs_type, flags, data, autofs_fill_super);
 }
 
-static struct file_system_type autofs_fs_type = {
+struct file_system_type autofs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "autofs",
 	.mount		= autofs_mount,


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/6] autofs - fix possible inode leak in autofs_fill_super()
  2018-11-13  1:35 [PATCH 1/6] autofs - improve ioctl sbi checks Ian Kent
@ 2018-11-13  1:36 ` Ian Kent
  2018-11-13  1:36 ` [PATCH 3/6] autofs - refactor super block info init Ian Kent
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Ian Kent @ 2018-11-13  1:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, autofs mailing list, Kernel Mailing List, linux-fsdevel

There is no check at all for a failure to allocate the root inode
in autofs_fill_super(), handle it.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 fs/autofs/inode.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 846c052569dd..e5c06b5a7371 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -254,9 +254,13 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
 		goto fail_free;
 	}
 	root_inode = autofs_get_inode(s, S_IFDIR | 0755);
+	if (!root_inode) {
+		ret = -ENOMEM;
+		goto fail_ino;
+	}
 	root = d_make_root(root_inode);
 	if (!root)
-		goto fail_ino;
+		goto fail_iput;
 	pipe = NULL;
 
 	root->d_fsdata = ino;
@@ -304,8 +308,8 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
 	root_inode->i_op = &autofs_dir_inode_operations;
 
 	pr_debug("pipe fd = %d, pgrp = %u\n", pipefd, pid_nr(sbi->oz_pgrp));
-	pipe = fget(pipefd);
 
+	pipe = fget(pipefd);
 	if (!pipe) {
 		pr_err("could not open pipe file descriptor\n");
 		goto fail_put_pid;
@@ -334,6 +338,8 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
 fail_dput:
 	dput(root);
 	goto fail_free;
+fail_iput:
+	iput(root_inode);
 fail_ino:
 	autofs_free_ino(ino);
 fail_free:


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/6] autofs - refactor super block info init
  2018-11-13  1:35 [PATCH 1/6] autofs - improve ioctl sbi checks Ian Kent
  2018-11-13  1:36 ` [PATCH 2/6] autofs - fix possible inode leak in autofs_fill_super() Ian Kent
@ 2018-11-13  1:36 ` Ian Kent
  2018-11-13  1:36 ` [PATCH 4/6] autofs - use struct for mount params Ian Kent
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Ian Kent @ 2018-11-13  1:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, autofs mailing list, Kernel Mailing List, linux-fsdevel

Move the allocation and initialisation of the super block
info struct to its own function.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 fs/autofs/inode.c |   46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index e5c06b5a7371..93af0d5777ae 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -201,43 +201,49 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
 	return (*pipefd < 0);
 }
 
-int autofs_fill_super(struct super_block *s, void *data, int silent)
+static struct autofs_sb_info *autofs_alloc_sbi(struct super_block *s)
 {
-	struct inode *root_inode;
-	struct dentry *root;
-	struct file *pipe;
-	int pipefd;
 	struct autofs_sb_info *sbi;
-	struct autofs_info *ino;
-	int pgrp = 0;
-	bool pgrp_set = false;
-	int ret = -EINVAL;
 
 	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
 	if (!sbi)
-		return -ENOMEM;
-	pr_debug("starting up, sbi = %p\n", sbi);
+		return NULL;
 
-	s->s_fs_info = sbi;
 	sbi->magic = AUTOFS_SBI_MAGIC;
+	sbi->sb = s;
 	sbi->pipefd = -1;
 	sbi->pipe = NULL;
 	sbi->catatonic = 1;
-	sbi->exp_timeout = 0;
-	sbi->oz_pgrp = NULL;
-	sbi->sb = s;
-	sbi->version = 0;
-	sbi->sub_version = 0;
 	set_autofs_type_indirect(&sbi->type);
-	sbi->min_proto = 0;
-	sbi->max_proto = 0;
 	mutex_init(&sbi->wq_mutex);
 	mutex_init(&sbi->pipe_mutex);
 	spin_lock_init(&sbi->fs_lock);
-	sbi->queues = NULL;
 	spin_lock_init(&sbi->lookup_lock);
 	INIT_LIST_HEAD(&sbi->active_list);
 	INIT_LIST_HEAD(&sbi->expiring_list);
+
+	return sbi;
+}
+
+int autofs_fill_super(struct super_block *s, void *data, int silent)
+{
+	struct inode *root_inode;
+	struct dentry *root;
+	struct file *pipe;
+	int pipefd;
+	struct autofs_sb_info *sbi;
+	struct autofs_info *ino;
+	int pgrp = 0;
+	bool pgrp_set = false;
+	int ret = -EINVAL;
+
+	sbi = autofs_alloc_sbi(s);
+	if (!sbi)
+		return -ENOMEM;
+
+	pr_debug("starting up, sbi = %p\n", sbi);
+
+	s->s_fs_info = sbi;
 	s->s_blocksize = 1024;
 	s->s_blocksize_bits = 10;
 	s->s_magic = AUTOFS_SUPER_MAGIC;


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/6] autofs - use struct for mount params
  2018-11-13  1:35 [PATCH 1/6] autofs - improve ioctl sbi checks Ian Kent
  2018-11-13  1:36 ` [PATCH 2/6] autofs - fix possible inode leak in autofs_fill_super() Ian Kent
  2018-11-13  1:36 ` [PATCH 3/6] autofs - refactor super block info init Ian Kent
@ 2018-11-13  1:36 ` Ian Kent
  2018-11-14  1:54   ` kbuild test robot
  2018-11-13  1:36 ` [PATCH 5/6] autofs - change catatonic setting to a bit flag Ian Kent
  2018-11-13  1:37 ` [PATCH 6/6] autofs - add strictexpire mount option Ian Kent
  4 siblings, 1 reply; 9+ messages in thread
From: Ian Kent @ 2018-11-13  1:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, autofs mailing list, Kernel Mailing List, linux-fsdevel

Use a structure to hold parsed parameters to simplify the
autofs_parse_options() function call.

Also seperate option parsing and applying the options into
seperate functions.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 fs/autofs/inode.c |  193 ++++++++++++++++++++++++++++++++---------------------
 1 file changed, 116 insertions(+), 77 deletions(-)

diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 93af0d5777ae..53ed6c637cbf 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -108,6 +108,17 @@ static const struct super_operations autofs_sops = {
 	.evict_inode	= autofs_evict_inode,
 };
 
+struct autofs_fs_params {
+	int pipefd;
+	kuid_t uid;
+	kgid_t gid;
+	int pgrp;
+	bool pgrp_set;
+	int min_proto;
+	int max_proto;
+	unsigned int type;
+};
+
 enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto,
 	Opt_indirect, Opt_direct, Opt_offset};
 
@@ -124,24 +135,26 @@ static const match_table_t tokens = {
 	{Opt_err, NULL}
 };
 
-static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
-			 int *pgrp, bool *pgrp_set, unsigned int *type,
-			 int *minproto, int *maxproto)
+static int autofs_parse_options(char *options, struct autofs_fs_params *params)
 {
 	char *p;
 	substring_t args[MAX_OPT_ARGS];
 	int option;
+	kuid_t uid;
+	kgid_t gid;
+
+	if (!options)
+		return 1;
 
-	*uid = current_uid();
-	*gid = current_gid();
+	params->pipefd = -1;
 
-	*minproto = AUTOFS_MIN_PROTO_VERSION;
-	*maxproto = AUTOFS_MAX_PROTO_VERSION;
+	params->uid = current_uid();
+	params->gid = current_gid();
 
-	*pipefd = -1;
+	params->min_proto = AUTOFS_MIN_PROTO_VERSION;
+	params->max_proto = AUTOFS_MAX_PROTO_VERSION;
 
-	if (!options)
-		return 1;
+	params->pgrp_set = false;
 
 	while ((p = strsep(&options, ",")) != NULL) {
 		int token;
@@ -152,53 +165,126 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
 		token = match_token(p, tokens, args);
 		switch (token) {
 		case Opt_fd:
-			if (match_int(args, pipefd))
+			if (match_int(args, &option))
 				return 1;
+			params->pipefd = option;
 			break;
 		case Opt_uid:
 			if (match_int(args, &option))
 				return 1;
-			*uid = make_kuid(current_user_ns(), option);
-			if (!uid_valid(*uid))
+			uid = make_kuid(current_user_ns(), option);
+			if (!uid_valid(uid))
 				return 1;
+			params->uid = uid;
 			break;
 		case Opt_gid:
 			if (match_int(args, &option))
 				return 1;
-			*gid = make_kgid(current_user_ns(), option);
-			if (!gid_valid(*gid))
+			gid = make_kgid(current_user_ns(), option);
+			if (!gid_valid(gid))
 				return 1;
+			params->gid = gid;
 			break;
 		case Opt_pgrp:
 			if (match_int(args, &option))
 				return 1;
-			*pgrp = option;
-			*pgrp_set = true;
+			params->pgrp = option;
+			params->pgrp_set = true;
 			break;
 		case Opt_minproto:
 			if (match_int(args, &option))
 				return 1;
-			*minproto = option;
+			params->min_proto = option;
 			break;
 		case Opt_maxproto:
 			if (match_int(args, &option))
 				return 1;
-			*maxproto = option;
+			params->max_proto = option;
 			break;
 		case Opt_indirect:
-			set_autofs_type_indirect(type);
+			set_autofs_type_indirect(&params->type);
 			break;
 		case Opt_direct:
-			set_autofs_type_direct(type);
+			set_autofs_type_direct(&params->type);
 			break;
 		case Opt_offset:
-			set_autofs_type_offset(type);
+			set_autofs_type_offset(&params->type);
 			break;
 		default:
 			return 1;
 		}
 	}
-	return (*pipefd < 0);
+	return (params->pipefd < 0);
+}
+
+static int autofs_apply_sbi_options(struct autofs_sb_info *sbi,
+				    struct autofs_fs_params *params)
+{
+	int err;
+
+	sbi->pipefd = params->pipefd;
+
+	if (params->type)
+		sbi->type = params->type;
+
+	/* Test versions first */
+	if (params->max_proto < AUTOFS_MIN_PROTO_VERSION ||
+	    params->min_proto > AUTOFS_MAX_PROTO_VERSION) {
+		pr_err("kernel does not match daemon version\n");
+		pr_err("daemon (%d, %d) kernel (%d, %d)\n",
+			params->min_proto, params->max_proto,
+			AUTOFS_MIN_PROTO_VERSION, AUTOFS_MAX_PROTO_VERSION);
+		goto out;
+	}
+
+	sbi->max_proto = params->max_proto;
+	sbi->min_proto = params->min_proto;
+
+	if (sbi->min_proto > sbi->max_proto)
+		sbi->min_proto = params->max_proto;
+
+	/* Establish highest kernel protocol version */
+	if (sbi->max_proto > AUTOFS_MAX_PROTO_VERSION)
+		sbi->version = AUTOFS_MAX_PROTO_VERSION;
+	else
+		sbi->version = params->max_proto;
+
+	sbi->sub_version = AUTOFS_PROTO_SUBVERSION;
+
+	if (!params->pgrp_set)
+		sbi->oz_pgrp = get_task_pid(current, PIDTYPE_PGID);
+	else {
+		sbi->oz_pgrp = find_get_pid(params->pgrp);
+		if (!sbi->oz_pgrp) {
+			pr_err("could not find process group %d\n",
+			       params->pgrp);
+			goto out;
+		}
+	}
+
+	pr_debug("pipe fd = %d, pgrp = %u\n",
+		  sbi->pipefd, pid_nr(sbi->oz_pgrp));
+
+	sbi->pipe = fget(sbi->pipefd);
+	if (!sbi->pipe) {
+		pr_err("could not open pipe file descriptor\n");
+		goto out_put_pid;
+	}
+
+	err = autofs_prepare_pipe(sbi->pipe);
+	if (err < 0)
+		goto out_fput;
+
+	sbi->catatonic = 0;
+
+	return 0;
+
+out_fput:
+	fput(sbi->pipe);
+out_put_pid:
+	put_pid(sbi->oz_pgrp);
+out:
+	return 1;
 }
 
 static struct autofs_sb_info *autofs_alloc_sbi(struct super_block *s)
@@ -229,12 +315,9 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
 {
 	struct inode *root_inode;
 	struct dentry *root;
-	struct file *pipe;
-	int pipefd;
+	struct autofs_fs_params params;
 	struct autofs_sb_info *sbi;
 	struct autofs_info *ino;
-	int pgrp = 0;
-	bool pgrp_set = false;
 	int ret = -EINVAL;
 
 	sbi = autofs_alloc_sbi(s);
@@ -267,45 +350,20 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
 	root = d_make_root(root_inode);
 	if (!root)
 		goto fail_iput;
-	pipe = NULL;
 
 	root->d_fsdata = ino;
 
-	/* Can this call block? */
-	if (parse_options(data, &pipefd, &root_inode->i_uid, &root_inode->i_gid,
-			  &pgrp, &pgrp_set, &sbi->type, &sbi->min_proto,
-			  &sbi->max_proto)) {
+	memset(&params, 0, sizeof(struct autofs_fs_params));
+	if (autofs_parse_options(data, &params)) {
 		pr_err("called with bogus options\n");
 		goto fail_dput;
 	}
+	root_inode->i_uid = params->uid;
+	root_inode->i_gid = params->gid;
 
-	/* Test versions first */
-	if (sbi->max_proto < AUTOFS_MIN_PROTO_VERSION ||
-	    sbi->min_proto > AUTOFS_MAX_PROTO_VERSION) {
-		pr_err("kernel does not match daemon version "
-		       "daemon (%d, %d) kernel (%d, %d)\n",
-		       sbi->min_proto, sbi->max_proto,
-		       AUTOFS_MIN_PROTO_VERSION, AUTOFS_MAX_PROTO_VERSION);
+	ret = autofs_apply_sbi_options(sbi, &params);
+	if (ret)
 		goto fail_dput;
-	}
-
-	/* Establish highest kernel protocol version */
-	if (sbi->max_proto > AUTOFS_MAX_PROTO_VERSION)
-		sbi->version = AUTOFS_MAX_PROTO_VERSION;
-	else
-		sbi->version = sbi->max_proto;
-	sbi->sub_version = AUTOFS_PROTO_SUBVERSION;
-
-	if (pgrp_set) {
-		sbi->oz_pgrp = find_get_pid(pgrp);
-		if (!sbi->oz_pgrp) {
-			pr_err("could not find process group %d\n",
-				pgrp);
-			goto fail_dput;
-		}
-	} else {
-		sbi->oz_pgrp = get_task_pid(current, PIDTYPE_PGID);
-	}
 
 	if (autofs_type_trigger(sbi->type))
 		__managed_dentry_set_managed(root);
@@ -313,20 +371,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
 	root_inode->i_fop = &autofs_root_operations;
 	root_inode->i_op = &autofs_dir_inode_operations;
 
-	pr_debug("pipe fd = %d, pgrp = %u\n", pipefd, pid_nr(sbi->oz_pgrp));
-
-	pipe = fget(pipefd);
-	if (!pipe) {
-		pr_err("could not open pipe file descriptor\n");
-		goto fail_put_pid;
-	}
-	ret = autofs_prepare_pipe(pipe);
-	if (ret < 0)
-		goto fail_fput;
-	sbi->pipe = pipe;
-	sbi->pipefd = pipefd;
-	sbi->catatonic = 0;
-
 	/*
 	 * Success! Install the root dentry now to indicate completion.
 	 */
@@ -336,11 +380,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
 	/*
 	 * Failure ... clean up.
 	 */
-fail_fput:
-	pr_err("pipe file descriptor does not contain proper ops\n");
-	fput(pipe);
-fail_put_pid:
-	put_pid(sbi->oz_pgrp);
 fail_dput:
 	dput(root);
 	goto fail_free;


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/6] autofs - change catatonic setting to a bit flag
  2018-11-13  1:35 [PATCH 1/6] autofs - improve ioctl sbi checks Ian Kent
                   ` (2 preceding siblings ...)
  2018-11-13  1:36 ` [PATCH 4/6] autofs - use struct for mount params Ian Kent
@ 2018-11-13  1:36 ` Ian Kent
  2018-11-13  1:37 ` [PATCH 6/6] autofs - add strictexpire mount option Ian Kent
  4 siblings, 0 replies; 9+ messages in thread
From: Ian Kent @ 2018-11-13  1:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, autofs mailing list, Kernel Mailing List, linux-fsdevel

Change the super block info. catatonic setting to be part of a
flags bit field.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 fs/autofs/autofs_i.h  |    7 +++++--
 fs/autofs/dev-ioctl.c |    4 ++--
 fs/autofs/inode.c     |    4 ++--
 fs/autofs/root.c      |   11 ++++++-----
 fs/autofs/waitq.c     |   10 +++++-----
 5 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index c4301e33c027..032cbb12531a 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -101,16 +101,18 @@ struct autofs_wait_queue {
 
 #define AUTOFS_SBI_MAGIC 0x6d4a556d
 
+#define AUTOFS_SBI_CATATONIC	0x0001
+
 struct autofs_sb_info {
 	u32 magic;
 	int pipefd;
 	struct file *pipe;
 	struct pid *oz_pgrp;
-	int catatonic;
 	int version;
 	int sub_version;
 	int min_proto;
 	int max_proto;
+	unsigned int flags;
 	unsigned long exp_timeout;
 	unsigned int type;
 	struct super_block *sb;
@@ -140,7 +142,8 @@ static inline struct autofs_info *autofs_dentry_ino(struct dentry *dentry)
  */
 static inline int autofs_oz_mode(struct autofs_sb_info *sbi)
 {
-	return sbi->catatonic || task_pgrp(current) == sbi->oz_pgrp;
+	return ((sbi->flags & AUTOFS_SBI_CATATONIC) ||
+		 task_pgrp(current) == sbi->oz_pgrp);
 }
 
 struct inode *autofs_get_inode(struct super_block *, umode_t);
diff --git a/fs/autofs/dev-ioctl.c b/fs/autofs/dev-ioctl.c
index 3de4f5e61caf..fc1caf449fa3 100644
--- a/fs/autofs/dev-ioctl.c
+++ b/fs/autofs/dev-ioctl.c
@@ -352,7 +352,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
 	pipefd = param->setpipefd.pipefd;
 
 	mutex_lock(&sbi->wq_mutex);
-	if (!sbi->catatonic) {
+	if (!(sbi->flags & AUTOFS_SBI_CATATONIC)) {
 		mutex_unlock(&sbi->wq_mutex);
 		return -EBUSY;
 	} else {
@@ -379,7 +379,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
 		swap(sbi->oz_pgrp, new_pid);
 		sbi->pipefd = pipefd;
 		sbi->pipe = pipe;
-		sbi->catatonic = 0;
+		sbi->flags &= ~AUTOFS_SBI_CATATONIC;
 	}
 out:
 	put_pid(new_pid);
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 53ed6c637cbf..5e774852ae84 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -275,7 +275,7 @@ static int autofs_apply_sbi_options(struct autofs_sb_info *sbi,
 	if (err < 0)
 		goto out_fput;
 
-	sbi->catatonic = 0;
+	sbi->flags &= ~AUTOFS_SBI_CATATONIC;
 
 	return 0;
 
@@ -299,7 +299,7 @@ static struct autofs_sb_info *autofs_alloc_sbi(struct super_block *s)
 	sbi->sb = s;
 	sbi->pipefd = -1;
 	sbi->pipe = NULL;
-	sbi->catatonic = 1;
+	sbi->flags = AUTOFS_SBI_CATATONIC;
 	set_autofs_type_indirect(&sbi->type);
 	mutex_init(&sbi->wq_mutex);
 	mutex_init(&sbi->pipe_mutex);
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 782e57b911ab..164ccd3402cf 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -510,7 +510,8 @@ static struct dentry *autofs_lookup(struct inode *dir,
 	sbi = autofs_sbi(dir->i_sb);
 
 	pr_debug("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n",
-		 current->pid, task_pgrp_nr(current), sbi->catatonic,
+		 current->pid, task_pgrp_nr(current),
+		 sbi->flags & AUTOFS_SBI_CATATONIC,
 		 autofs_oz_mode(sbi));
 
 	active = autofs_lookup_active(dentry);
@@ -563,7 +564,7 @@ static int autofs_dir_symlink(struct inode *dir,
 	 * autofs mount is catatonic but the state of an autofs
 	 * file system needs to be preserved over restarts.
 	 */
-	if (sbi->catatonic)
+	if (sbi->flags & AUTOFS_SBI_CATATONIC)
 		return -EACCES;
 
 	BUG_ON(!ino);
@@ -626,7 +627,7 @@ static int autofs_dir_unlink(struct inode *dir, struct dentry *dentry)
 	 * autofs mount is catatonic but the state of an autofs
 	 * file system needs to be preserved over restarts.
 	 */
-	if (sbi->catatonic)
+	if (sbi->flags & AUTOFS_SBI_CATATONIC)
 		return -EACCES;
 
 	if (atomic_dec_and_test(&ino->count)) {
@@ -714,7 +715,7 @@ static int autofs_dir_rmdir(struct inode *dir, struct dentry *dentry)
 	 * autofs mount is catatonic but the state of an autofs
 	 * file system needs to be preserved over restarts.
 	 */
-	if (sbi->catatonic)
+	if (sbi->flags & AUTOFS_SBI_CATATONIC)
 		return -EACCES;
 
 	spin_lock(&sbi->lookup_lock);
@@ -759,7 +760,7 @@ static int autofs_dir_mkdir(struct inode *dir,
 	 * autofs mount is catatonic but the state of an autofs
 	 * file system needs to be preserved over restarts.
 	 */
-	if (sbi->catatonic)
+	if (sbi->flags & AUTOFS_SBI_CATATONIC)
 		return -EACCES;
 
 	pr_debug("dentry %p, creating %pd\n", dentry, dentry);
diff --git a/fs/autofs/waitq.c b/fs/autofs/waitq.c
index f6385c6ef0a5..15a3e31d0904 100644
--- a/fs/autofs/waitq.c
+++ b/fs/autofs/waitq.c
@@ -20,14 +20,14 @@ void autofs_catatonic_mode(struct autofs_sb_info *sbi)
 	struct autofs_wait_queue *wq, *nwq;
 
 	mutex_lock(&sbi->wq_mutex);
-	if (sbi->catatonic) {
+	if (sbi->flags & AUTOFS_SBI_CATATONIC) {
 		mutex_unlock(&sbi->wq_mutex);
 		return;
 	}
 
 	pr_debug("entering catatonic mode\n");
 
-	sbi->catatonic = 1;
+	sbi->flags |= AUTOFS_SBI_CATATONIC;
 	wq = sbi->queues;
 	sbi->queues = NULL;	/* Erase all wait queues */
 	while (wq) {
@@ -255,7 +255,7 @@ static int validate_request(struct autofs_wait_queue **wait,
 	struct autofs_wait_queue *wq;
 	struct autofs_info *ino;
 
-	if (sbi->catatonic)
+	if (sbi->flags & AUTOFS_SBI_CATATONIC)
 		return -ENOENT;
 
 	/* Wait in progress, continue; */
@@ -290,7 +290,7 @@ static int validate_request(struct autofs_wait_queue **wait,
 			if (mutex_lock_interruptible(&sbi->wq_mutex))
 				return -EINTR;
 
-			if (sbi->catatonic)
+			if (sbi->flags & AUTOFS_SBI_CATATONIC)
 				return -ENOENT;
 
 			wq = autofs_find_wait(sbi, qstr);
@@ -359,7 +359,7 @@ int autofs_wait(struct autofs_sb_info *sbi,
 	pid_t tgid;
 
 	/* In catatonic mode, we don't wait for nobody */
-	if (sbi->catatonic)
+	if (sbi->flags & AUTOFS_SBI_CATATONIC)
 		return -ENOENT;
 
 	/*


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 6/6] autofs - add strictexpire mount option
  2018-11-13  1:35 [PATCH 1/6] autofs - improve ioctl sbi checks Ian Kent
                   ` (3 preceding siblings ...)
  2018-11-13  1:36 ` [PATCH 5/6] autofs - change catatonic setting to a bit flag Ian Kent
@ 2018-11-13  1:37 ` Ian Kent
  2018-11-15 13:26   ` kbuild test robot
  4 siblings, 1 reply; 9+ messages in thread
From: Ian Kent @ 2018-11-13  1:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, autofs mailing list, Kernel Mailing List, linux-fsdevel

Commit 092a53452b (("autofs: take more care to not update last_used
on path walk") helped to (partially) resolve a problem where automounts
were not expiring due to aggressive accesses from user space.

This patch was later reverted because, for very large environments,
it meant more mount requests from clients and when there are a lot
of clients this caused a fairly significant increase in server load.

But there is a need for both types of expire check, depending on use
case, so add a mount option to allow for strict update of last use
of autofs dentrys (which just means not updating the last use on path
walk accesses).

Signed-off-by: Ian Kent <raven@themaw.net>
---
 fs/autofs/autofs_i.h         |    1 +
 fs/autofs/inode.c            |   13 ++++++++++++-
 fs/autofs/root.c             |    5 ++++-
 include/uapi/linux/auto_fs.h |    2 +-
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index 032cbb12531a..fa3733beb52e 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -102,6 +102,7 @@ struct autofs_wait_queue {
 #define AUTOFS_SBI_MAGIC 0x6d4a556d
 
 #define AUTOFS_SBI_CATATONIC	0x0001
+#define AUTOFS_SBI_STRICTEXPIRE 0x0002
 
 struct autofs_sb_info {
 	u32 magic;
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 5e774852ae84..75d61f5a3069 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -87,6 +87,8 @@ static int autofs_show_options(struct seq_file *m, struct dentry *root)
 		seq_printf(m, ",direct");
 	else
 		seq_printf(m, ",indirect");
+	if (sbi->flags & AUTOFS_SBI_STRICTEXPIRE)
+		seq_printf(m, ",strictexpire");
 #ifdef CONFIG_CHECKPOINT_RESTORE
 	if (sbi->pipe)
 		seq_printf(m, ",pipe_ino=%ld", file_inode(sbi->pipe)->i_ino);
@@ -116,11 +118,12 @@ struct autofs_fs_params {
 	bool pgrp_set;
 	int min_proto;
 	int max_proto;
+	bool strictexpire;
 	unsigned int type;
 };
 
 enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto,
-	Opt_indirect, Opt_direct, Opt_offset};
+	Opt_indirect, Opt_direct, Opt_offset, Opt_strictexpire};
 
 static const match_table_t tokens = {
 	{Opt_fd, "fd=%u"},
@@ -132,6 +135,7 @@ static const match_table_t tokens = {
 	{Opt_indirect, "indirect"},
 	{Opt_direct, "direct"},
 	{Opt_offset, "offset"},
+	{Opt_strictexpire, "strictexpire"},
 	{Opt_err, NULL}
 };
 
@@ -155,6 +159,7 @@ static int autofs_parse_options(char *options, struct autofs_fs_params *params)
 	params->max_proto = AUTOFS_MAX_PROTO_VERSION;
 
 	params->pgrp_set = false;
+	params->strictexpire = false;
 
 	while ((p = strsep(&options, ",")) != NULL) {
 		int token;
@@ -210,6 +215,9 @@ static int autofs_parse_options(char *options, struct autofs_fs_params *params)
 		case Opt_offset:
 			set_autofs_type_offset(&params->type);
 			break;
+		case Opt_strictexpire:
+			params->strictexpire = true;
+			break;
 		default:
 			return 1;
 		}
@@ -275,6 +283,9 @@ static int autofs_apply_sbi_options(struct autofs_sb_info *sbi,
 	if (err < 0)
 		goto out_fput;
 
+	if (params->strictexpire)
+		sbi->flags |= AUTOFS_SBI_STRICTEXPIRE;
+
 	sbi->flags &= ~AUTOFS_SBI_CATATONIC;
 
 	return 0;
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 164ccd3402cf..1246f396bf0e 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -275,8 +275,11 @@ static int autofs_mount_wait(const struct path *path, bool rcu_walk)
 		pr_debug("waiting for mount name=%pd\n", path->dentry);
 		status = autofs_wait(sbi, path, NFY_MOUNT);
 		pr_debug("mount wait done status=%d\n", status);
+		ino->last_used = jiffies;
+		return status;
 	}
-	ino->last_used = jiffies;
+	if (!(sbi->flags & AUTOFS_SBI_STRICTEXPIRE))
+		ino->last_used = jiffies;
 	return status;
 }
 
diff --git a/include/uapi/linux/auto_fs.h b/include/uapi/linux/auto_fs.h
index df31aa9c9a8c..082119630b49 100644
--- a/include/uapi/linux/auto_fs.h
+++ b/include/uapi/linux/auto_fs.h
@@ -23,7 +23,7 @@
 #define AUTOFS_MIN_PROTO_VERSION	3
 #define AUTOFS_MAX_PROTO_VERSION	5
 
-#define AUTOFS_PROTO_SUBVERSION		3
+#define AUTOFS_PROTO_SUBVERSION		4
 
 /*
  * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/6] autofs - use struct for mount params
  2018-11-13  1:36 ` [PATCH 4/6] autofs - use struct for mount params Ian Kent
@ 2018-11-14  1:54   ` kbuild test robot
  2018-11-14  5:56     ` Ian Kent
  0 siblings, 1 reply; 9+ messages in thread
From: kbuild test robot @ 2018-11-14  1:54 UTC (permalink / raw)
  To: Ian Kent
  Cc: kbuild-all, Andrew Morton, Al Viro, autofs mailing list,
	Kernel Mailing List, linux-fsdevel

[-- Attachment #1: Type: text/plain, Size: 3415 bytes --]

Hi Ian,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.20-rc2]
[cannot apply to next-20181113]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Ian-Kent/autofs-improve-ioctl-sbi-checks/20181114-021150
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   fs/autofs/inode.c: In function 'autofs_fill_super':
>> fs/autofs/inode.c:361:28: error: invalid type argument of '->' (have 'struct autofs_fs_params')
     root_inode->i_uid = params->uid;
                               ^~
   fs/autofs/inode.c:362:28: error: invalid type argument of '->' (have 'struct autofs_fs_params')
     root_inode->i_gid = params->gid;
                               ^~

vim +361 fs/autofs/inode.c

   313	
   314	int autofs_fill_super(struct super_block *s, void *data, int silent)
   315	{
   316		struct inode *root_inode;
   317		struct dentry *root;
   318		struct autofs_fs_params params;
   319		struct autofs_sb_info *sbi;
   320		struct autofs_info *ino;
   321		int ret = -EINVAL;
   322	
   323		sbi = autofs_alloc_sbi(s);
   324		if (!sbi)
   325			return -ENOMEM;
   326	
   327		pr_debug("starting up, sbi = %p\n", sbi);
   328	
   329		s->s_fs_info = sbi;
   330		s->s_blocksize = 1024;
   331		s->s_blocksize_bits = 10;
   332		s->s_magic = AUTOFS_SUPER_MAGIC;
   333		s->s_op = &autofs_sops;
   334		s->s_d_op = &autofs_dentry_operations;
   335		s->s_time_gran = 1;
   336	
   337		/*
   338		 * Get the root inode and dentry, but defer checking for errors.
   339		 */
   340		ino = autofs_new_ino(sbi);
   341		if (!ino) {
   342			ret = -ENOMEM;
   343			goto fail_free;
   344		}
   345		root_inode = autofs_get_inode(s, S_IFDIR | 0755);
   346		if (!root_inode) {
   347			ret = -ENOMEM;
   348			goto fail_ino;
   349		}
   350		root = d_make_root(root_inode);
   351		if (!root)
   352			goto fail_iput;
   353	
   354		root->d_fsdata = ino;
   355	
   356		memset(&params, 0, sizeof(struct autofs_fs_params));
   357		if (autofs_parse_options(data, &params)) {
   358			pr_err("called with bogus options\n");
   359			goto fail_dput;
   360		}
 > 361		root_inode->i_uid = params->uid;
   362		root_inode->i_gid = params->gid;
   363	
   364		ret = autofs_apply_sbi_options(sbi, &params);
   365		if (ret)
   366			goto fail_dput;
   367	
   368		if (autofs_type_trigger(sbi->type))
   369			__managed_dentry_set_managed(root);
   370	
   371		root_inode->i_fop = &autofs_root_operations;
   372		root_inode->i_op = &autofs_dir_inode_operations;
   373	
   374		/*
   375		 * Success! Install the root dentry now to indicate completion.
   376		 */
   377		s->s_root = root;
   378		return 0;
   379	
   380		/*
   381		 * Failure ... clean up.
   382		 */
   383	fail_dput:
   384		dput(root);
   385		goto fail_free;
   386	fail_iput:
   387		iput(root_inode);
   388	fail_ino:
   389		autofs_free_ino(ino);
   390	fail_free:
   391		kfree(sbi);
   392		s->s_fs_info = NULL;
   393		return ret;
   394	}
   395	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 66026 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/6] autofs - use struct for mount params
  2018-11-14  1:54   ` kbuild test robot
@ 2018-11-14  5:56     ` Ian Kent
  0 siblings, 0 replies; 9+ messages in thread
From: Ian Kent @ 2018-11-14  5:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: kbuild-all, Al Viro, autofs mailing list, Kernel Mailing List,
	linux-fsdevel

On Wed, 2018-11-14 at 09:54 +0800, kbuild test robot wrote:
> Hi Ian,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on linus/master]
> [also build test ERROR on v4.20-rc2]
> [cannot apply to next-20181113]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system]
> 
> url:    
> https://github.com/0day-ci/linux/commits/Ian-Kent/autofs-improve-ioctl-sbi-checks/20181114-021150
> config: i386-allmodconfig (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=i386 
> 
> All errors (new ones prefixed by >>):
> 
>    fs/autofs/inode.c: In function 'autofs_fill_super':
> > > fs/autofs/inode.c:361:28: error: invalid type argument of '->' (have
> > > 'struct autofs_fs_params')
> 
>      root_inode->i_uid = params->uid;
>                                ^~
>    fs/autofs/inode.c:362:28: error: invalid type argument of '->' (have
> 'struct autofs_fs_params')
>      root_inode->i_gid = params->gid;
>                                ^~

Oh, I fixed that, I must have messed up somewhere, I'll check what I have
again.

Andrew, due to the patch order dependencies I think it would be best for
me to re-post the series so please ignore this series.

I'll put a v2 in the title of the re-posted series so they can be identified
(is that the right thing to do?).

> 
> vim +361 fs/autofs/inode.c
> 
>    313	
>    314	int autofs_fill_super(struct super_block *s, void *data, int
> silent)
>    315	{
>    316		struct inode *root_inode;
>    317		struct dentry *root;
>    318		struct autofs_fs_params params;
>    319		struct autofs_sb_info *sbi;
>    320		struct autofs_info *ino;
>    321		int ret = -EINVAL;
>    322	
>    323		sbi = autofs_alloc_sbi(s);
>    324		if (!sbi)
>    325			return -ENOMEM;
>    326	
>    327		pr_debug("starting up, sbi = %p\n", sbi);
>    328	
>    329		s->s_fs_info = sbi;
>    330		s->s_blocksize = 1024;
>    331		s->s_blocksize_bits = 10;
>    332		s->s_magic = AUTOFS_SUPER_MAGIC;
>    333		s->s_op = &autofs_sops;
>    334		s->s_d_op = &autofs_dentry_operations;
>    335		s->s_time_gran = 1;
>    336	
>    337		/*
>    338		 * Get the root inode and dentry, but defer checking for
> errors.
>    339		 */
>    340		ino = autofs_new_ino(sbi);
>    341		if (!ino) {
>    342			ret = -ENOMEM;
>    343			goto fail_free;
>    344		}
>    345		root_inode = autofs_get_inode(s, S_IFDIR | 0755);
>    346		if (!root_inode) {
>    347			ret = -ENOMEM;
>    348			goto fail_ino;
>    349		}
>    350		root = d_make_root(root_inode);
>    351		if (!root)
>    352			goto fail_iput;
>    353	
>    354		root->d_fsdata = ino;
>    355	
>    356		memset(&params, 0, sizeof(struct autofs_fs_params));
>    357		if (autofs_parse_options(data, &params)) {
>    358			pr_err("called with bogus options\n");
>    359			goto fail_dput;
>    360		}
>  > 361		root_inode->i_uid = params->uid;
>    362		root_inode->i_gid = params->gid;
>    363	
>    364		ret = autofs_apply_sbi_options(sbi, &params);
>    365		if (ret)
>    366			goto fail_dput;
>    367	
>    368		if (autofs_type_trigger(sbi->type))
>    369			__managed_dentry_set_managed(root);
>    370	
>    371		root_inode->i_fop = &autofs_root_operations;
>    372		root_inode->i_op = &autofs_dir_inode_operations;
>    373	
>    374		/*
>    375		 * Success! Install the root dentry now to indicate
> completion.
>    376		 */
>    377		s->s_root = root;
>    378		return 0;
>    379	
>    380		/*
>    381		 * Failure ... clean up.
>    382		 */
>    383	fail_dput:
>    384		dput(root);
>    385		goto fail_free;
>    386	fail_iput:
>    387		iput(root_inode);
>    388	fail_ino:
>    389		autofs_free_ino(ino);
>    390	fail_free:
>    391		kfree(sbi);
>    392		s->s_fs_info = NULL;
>    393		return ret;
>    394	}
>    395	
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 6/6] autofs - add strictexpire mount option
  2018-11-13  1:37 ` [PATCH 6/6] autofs - add strictexpire mount option Ian Kent
@ 2018-11-15 13:26   ` kbuild test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2018-11-15 13:26 UTC (permalink / raw)
  To: Ian Kent
  Cc: kbuild-all, Andrew Morton, Al Viro, autofs mailing list,
	Kernel Mailing List, linux-fsdevel

[-- Attachment #1: Type: text/plain, Size: 6531 bytes --]

Hi Ian,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.20-rc2]
[cannot apply to next-20181115]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Ian-Kent/autofs-improve-ioctl-sbi-checks/20181114-021150
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

>> fs/autofs/init.c:19:25: warning: symbol 'autofs_fs_type' was not declared. Should it be static?
--
   include/linux/slab.h:332:43: warning: dubious: x & !y
   include/linux/slab.h:332:43: warning: dubious: x & !y
>> fs/autofs/inode.c:372:35: error: cannot dereference this type
   fs/autofs/inode.c:373:35: error: cannot dereference this type
>> fs/autofs/inode.c:372:35: warning: unknown expression (8 46)
   fs/autofs/inode.c:373:35: warning: unknown expression (8 46)
   fs/autofs/inode.c: In function 'autofs_fill_super':
   fs/autofs/inode.c:372:28: error: invalid type argument of '->' (have 'struct autofs_fs_params')
     root_inode->i_uid = params->uid;
                               ^~
   fs/autofs/inode.c:373:28: error: invalid type argument of '->' (have 'struct autofs_fs_params')
     root_inode->i_gid = params->gid;
                               ^~

vim +372 fs/autofs/inode.c

e35160168 Ian Kent 2018-11-13  324  
e35160168 Ian Kent 2018-11-13  325  int autofs_fill_super(struct super_block *s, void *data, int silent)
e35160168 Ian Kent 2018-11-13  326  {
e35160168 Ian Kent 2018-11-13  327  	struct inode *root_inode;
e35160168 Ian Kent 2018-11-13  328  	struct dentry *root;
f4507adde Ian Kent 2018-11-13  329  	struct autofs_fs_params params;
e35160168 Ian Kent 2018-11-13  330  	struct autofs_sb_info *sbi;
e35160168 Ian Kent 2018-11-13  331  	struct autofs_info *ino;
e35160168 Ian Kent 2018-11-13  332  	int ret = -EINVAL;
e35160168 Ian Kent 2018-11-13  333  
e35160168 Ian Kent 2018-11-13  334  	sbi = autofs_alloc_sbi(s);
e35160168 Ian Kent 2018-11-13  335  	if (!sbi)
e35160168 Ian Kent 2018-11-13  336  		return -ENOMEM;
e35160168 Ian Kent 2018-11-13  337  
e35160168 Ian Kent 2018-11-13  338  	pr_debug("starting up, sbi = %p\n", sbi);
e35160168 Ian Kent 2018-11-13  339  
e35160168 Ian Kent 2018-11-13  340  	s->s_fs_info = sbi;
ebc921ca9 Ian Kent 2018-06-07  341  	s->s_blocksize = 1024;
ebc921ca9 Ian Kent 2018-06-07  342  	s->s_blocksize_bits = 10;
ebc921ca9 Ian Kent 2018-06-07  343  	s->s_magic = AUTOFS_SUPER_MAGIC;
ebc921ca9 Ian Kent 2018-06-07  344  	s->s_op = &autofs_sops;
ebc921ca9 Ian Kent 2018-06-07  345  	s->s_d_op = &autofs_dentry_operations;
ebc921ca9 Ian Kent 2018-06-07  346  	s->s_time_gran = 1;
ebc921ca9 Ian Kent 2018-06-07  347  
ebc921ca9 Ian Kent 2018-06-07  348  	/*
ebc921ca9 Ian Kent 2018-06-07  349  	 * Get the root inode and dentry, but defer checking for errors.
ebc921ca9 Ian Kent 2018-06-07  350  	 */
ebc921ca9 Ian Kent 2018-06-07  351  	ino = autofs_new_ino(sbi);
ebc921ca9 Ian Kent 2018-06-07  352  	if (!ino) {
ebc921ca9 Ian Kent 2018-06-07  353  		ret = -ENOMEM;
ebc921ca9 Ian Kent 2018-06-07  354  		goto fail_free;
ebc921ca9 Ian Kent 2018-06-07  355  	}
ebc921ca9 Ian Kent 2018-06-07  356  	root_inode = autofs_get_inode(s, S_IFDIR | 0755);
eef302f31 Ian Kent 2018-11-13  357  	if (!root_inode) {
eef302f31 Ian Kent 2018-11-13  358  		ret = -ENOMEM;
eef302f31 Ian Kent 2018-11-13  359  		goto fail_ino;
eef302f31 Ian Kent 2018-11-13  360  	}
ebc921ca9 Ian Kent 2018-06-07  361  	root = d_make_root(root_inode);
ebc921ca9 Ian Kent 2018-06-07  362  	if (!root)
eef302f31 Ian Kent 2018-11-13  363  		goto fail_iput;
ebc921ca9 Ian Kent 2018-06-07  364  
ebc921ca9 Ian Kent 2018-06-07  365  	root->d_fsdata = ino;
ebc921ca9 Ian Kent 2018-06-07  366  
f4507adde Ian Kent 2018-11-13  367  	memset(&params, 0, sizeof(struct autofs_fs_params));
f4507adde Ian Kent 2018-11-13  368  	if (autofs_parse_options(data, &params)) {
ebc921ca9 Ian Kent 2018-06-07  369  		pr_err("called with bogus options\n");
ebc921ca9 Ian Kent 2018-06-07  370  		goto fail_dput;
ebc921ca9 Ian Kent 2018-06-07  371  	}
f4507adde Ian Kent 2018-11-13 @372  	root_inode->i_uid = params->uid;
f4507adde Ian Kent 2018-11-13  373  	root_inode->i_gid = params->gid;
ebc921ca9 Ian Kent 2018-06-07  374  
f4507adde Ian Kent 2018-11-13  375  	ret = autofs_apply_sbi_options(sbi, &params);
f4507adde Ian Kent 2018-11-13  376  	if (ret)
ebc921ca9 Ian Kent 2018-06-07  377  		goto fail_dput;
ebc921ca9 Ian Kent 2018-06-07  378  
ebc921ca9 Ian Kent 2018-06-07  379  	if (autofs_type_trigger(sbi->type))
ebc921ca9 Ian Kent 2018-06-07  380  		__managed_dentry_set_managed(root);
ebc921ca9 Ian Kent 2018-06-07  381  
ebc921ca9 Ian Kent 2018-06-07  382  	root_inode->i_fop = &autofs_root_operations;
ebc921ca9 Ian Kent 2018-06-07  383  	root_inode->i_op = &autofs_dir_inode_operations;
ebc921ca9 Ian Kent 2018-06-07  384  
ebc921ca9 Ian Kent 2018-06-07  385  	/*
ebc921ca9 Ian Kent 2018-06-07  386  	 * Success! Install the root dentry now to indicate completion.
ebc921ca9 Ian Kent 2018-06-07  387  	 */
ebc921ca9 Ian Kent 2018-06-07  388  	s->s_root = root;
ebc921ca9 Ian Kent 2018-06-07  389  	return 0;
ebc921ca9 Ian Kent 2018-06-07  390  
ebc921ca9 Ian Kent 2018-06-07  391  	/*
ebc921ca9 Ian Kent 2018-06-07  392  	 * Failure ... clean up.
ebc921ca9 Ian Kent 2018-06-07  393  	 */
ebc921ca9 Ian Kent 2018-06-07  394  fail_dput:
ebc921ca9 Ian Kent 2018-06-07  395  	dput(root);
ebc921ca9 Ian Kent 2018-06-07  396  	goto fail_free;
eef302f31 Ian Kent 2018-11-13  397  fail_iput:
eef302f31 Ian Kent 2018-11-13  398  	iput(root_inode);
ebc921ca9 Ian Kent 2018-06-07  399  fail_ino:
ebc921ca9 Ian Kent 2018-06-07  400  	autofs_free_ino(ino);
ebc921ca9 Ian Kent 2018-06-07  401  fail_free:
ebc921ca9 Ian Kent 2018-06-07  402  	kfree(sbi);
ebc921ca9 Ian Kent 2018-06-07  403  	s->s_fs_info = NULL;
ebc921ca9 Ian Kent 2018-06-07  404  	return ret;
ebc921ca9 Ian Kent 2018-06-07  405  }
ebc921ca9 Ian Kent 2018-06-07  406  

:::::: The code at line 372 was first introduced by commit
:::::: f4507adde6ebc94c273ccc2c18f2afb0fea20cf9 autofs - use struct for mount params

:::::: TO: Ian Kent <raven@themaw.net>
:::::: CC: 0day robot <lkp@intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 66620 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-11-15 13:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13  1:35 [PATCH 1/6] autofs - improve ioctl sbi checks Ian Kent
2018-11-13  1:36 ` [PATCH 2/6] autofs - fix possible inode leak in autofs_fill_super() Ian Kent
2018-11-13  1:36 ` [PATCH 3/6] autofs - refactor super block info init Ian Kent
2018-11-13  1:36 ` [PATCH 4/6] autofs - use struct for mount params Ian Kent
2018-11-14  1:54   ` kbuild test robot
2018-11-14  5:56     ` Ian Kent
2018-11-13  1:36 ` [PATCH 5/6] autofs - change catatonic setting to a bit flag Ian Kent
2018-11-13  1:37 ` [PATCH 6/6] autofs - add strictexpire mount option Ian Kent
2018-11-15 13:26   ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).