Skip to contentSkip to conversation

autofs Digest, Vol 65, Issue 7

DISCUSSION Jim Dennis 1 participant 2 messages Aug 8, 2008 1 message not in the archive Kernel automounter

lore
Share & tools
lore

Jim Dennis

author
#1 lore raw
In reply to a message not in the archive

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of [email protected]
Sent: Friday, August 08, 2008 5:00 AM
To: [email protected]
Subject: autofs Digest, Vol 65, Issue 7

Send autofs mailing list submissions to
[email protected]

To subscribe or unsubscribe via the World Wide Web, visit
http://linux.kernel.org/mailman/listinfo/autofs
or, via email, send a message with subject or body 'help' to
[email protected]

You can reach the person managing the list at
[email protected]

When replying, please edit your Subject line so it is more specific than "Re: Contents of autofs digest..."

Today's Topics:

1. Re: [PATCH 2/4] autofs4 - track uid and gid of last mount requester (Ian Kent)
2. Re: [PATCH 4/4] autofs4 - add miscelaneous device for ioctls
(Andrew Morton)
3. Re: [PATCH 2/4] autofs4 - track uid and gid of last mount requester (Ian Kent)
4. Re: [PATCH 4/4] autofs4 - add miscelaneous device for ioctls
(Ian Kent)
5. Re: [PATCH 4/4] autofs4 - add miscelaneous device for ioctls
(Andrew Morton)

----------------------------------------------------------------------

Message: 1
Date: Fri, 08 Aug 2008 12:44:02 +0800
From: Ian Kent <[email protected]>
Subject: Re: [autofs] [PATCH 2/4] autofs4 - track uid and gid of last
mount requester
To: "Serge E. Hallyn" <[email protected]>
Cc: [email protected], [email protected], Andrew
Morton <[email protected]>,
[email protected],
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain

Quoted 37 lines · Ian Kent
Quoted 6 lines
Quoted 5 lines

Please remind me again why autofs's use of current->uid and current->gid is not busted in the presence of PID namespaces, current->where
these things are no longer system-wide unique?

Quoted 8 lines

I actually don't see what the autofs4_waitq->pid is used for. It's copied from current into wq->pid at autofs4_wait, and into a packet to send to userspace (I assume) at autofs4_notify_daemon.

So as long as a daemon can serve multiple pid namespaces (which doubtless it can), the pid could be confusing (or erroneous) for the

daemon.

Your point is well taken.

The pid is used purely for logging purposes to aid in debugging in user space. I'm not sure it is worth worrying about it too much as the

daemon has no business interfering with user space processes it is not

the owner of.

Quoted 5 lines

If I'm remotely right about how the pid is being used, then the thing to do would be to
1. store the daemon's pid namespace (would that belong in the autofs_sb_info?)

Yep.

Quoted 5 lines

2. store the task_pid(current) in the waitqueue
3. retrieve the pid_t for the waiting task in the daemon's pid namespace, and put that into the packet at autofs4_notify_daemon.

Quoted 5 lines
Quoted 2 lines

I realize this patch was about the *uids*, but the pids seem more urgent.

OK, I get it.
I'll have a go at doing this for completeness.

On second thoughts I'm not sure about this.

The pid that is logged needs to relate to a process in the name space of the one that caused the mount to be done.

For example, suppose a GUI user finds mounts never expiring, then we get a debug log to try and identify the culprit. So the pid should correspond to a process that the user sees (So I guess in the namespace of that user).

This is the only reason I added the pid to the request packet in the first place.

Please correct me if my understanding of this is not right.

Ian

Quoted 3 lines

Ian

------------------------------

Message: 2
Date: Thu, 7 Aug 2008 22:31:09 -0700
From: Andrew Morton <[email protected]>
Subject: Re: [autofs] [PATCH 4/4] autofs4 - add miscelaneous device
for ioctls
To: Ian Kent <[email protected]>
Cc: [email protected], [email protected],
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Quoted 5 lines · On Fri, 08 Aug 2008 11:39:19 +0800 Ian Kent <[email protected]> wrote:
Quoted 3 lines · Andrew Morton
Quoted 1 line · On Thu, 07 Aug 2008 19:40:31 +0800 Ian Kent <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Subject: [PATCH 4/4] autofs4 - add miscelaneous device for ioctls

I fixed that spello

Quoted 3 lines

Patch to add a miscellaneous device to the autofs4 module for routing ioctls. This provides the ability to obtain an ioctl file handle for an autofs mount point that is possibly covered by

another mount.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The actual problem with autofs is that it can't reconnect to existing mounts. Immediately one things of just adding the ability

to remount autofs file systems would solve it, but alas, that can't work. This is because autofs direct mounts and the implementation of "on demand mount and expire" of nested mount trees have the file system mounted on top of the mount trigger

dentry.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

To resolve this a miscellaneous device node for routing ioctl commands to these mount points has been implemented in the autofs4

kernel module and a library added to autofs. This provides the ability to open a file descriptor for these over mounted autofs

mount points.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Please refer to Documentation/filesystems/autofs4-mount-control.txt for a discussion of the problem, implementation alternatives considered

and a description of the interface.

Quoted 12 lines
Quoted 11 lines

Review

Quoted 9 lines

...

(quoted diff) +5 -0
+
+#define AUTOFS_DEV_IOCTL_SIZE	sizeof(struct autofs_dev_ioctl)
+
+typedef int (*ioctl_fn)(struct file *, struct autofs_sb_info *, 
+struct autofs_dev_ioctl *);

Weird layout, which I fixed.

Quoted 2 lines

Auuuhh .. didn't want to do this. I personally like declarations like this to be on a single line but checkpatch.pl complained about it.

Well, that's why it's a checkpatch warning, not an error. The way I look at checkpatch is that it is for detecting possible mistakes. Did you _really_ mean to do that? Usually the answer is "nope, and I wouldn't have noticed unless you told me". But sometimes the answer is "yes, I really did mean that".

I routinely ignore checkpatch 80-col warnings, unless they are flagging something which is just egregiously revolting.

Anyway, that's an aside. Given that you decided to fit that typedef into 80 cols, the way you did it was weird ;)

Quoted 29 lines
Quoted 17 lines

Review

Quoted 11 lines
(quoted diff) +11 -0
+static void autofs_dev_ioctl_fd_install(unsigned int fd, struct 
+file *file) {
+	struct files_struct *files = current->files;
+	struct fdtable *fdt;
+
+	spin_lock(&files->file_lock);
+	fdt = files_fdtable(files);
+	rcu_assign_pointer(fdt->fd[fd], file);
+	FD_SET(fd, fdt->close_on_exec);
+	spin_unlock(&files->file_lock);
+}

urgh, it's bad to have done a copy-n-paste on fd_install() here. It

means that if we go and change the locking in core kernel (quite possible) then people won't udpate this code.

Quoted 8 lines

Do we have alternative here? Can we set close_on_exec outside the lock and just call fd_install()? Probably not.

Can we export set_close_on_exec() then call that after having called

fd_install()? I think so.

But not this, please.

No problem.
You mentioned this last time as well.

Quoted 7 lines

Since there are a couple of possible approaches and I wasn't sure which way to go I thought I'd post it as is and get feedback then make

it a followup patch.

Could the pthreads user space daemon exec something between fd_install() and set_close_on_exec()?

Gee, I don't know, it would depend on the context.

Is that a private file*? Was it just created, and is there no possibility that any other thread can be sharing it anyway? If so, there's no problem.

Quoted 3 lines

Perhaps there are some other alternative approaches to this.

Suggestions?

I don't know enough about autofs nor about what problem you're attacking here to be able to say, sorry. I don't even know why close_on_exec is being set?

------------------------------

Message: 3
Date: Fri, 08 Aug 2008 13:37:41 +0800
From: Ian Kent <[email protected]>
Subject: Re: [autofs] [PATCH 2/4] autofs4 - track uid and gid of last
mount requester
To: Andrew Morton <[email protected]>
Cc: [email protected], [email protected],
[email protected], [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain

Quoted 8 lines · Ian Kent
Quoted 7 lines · Andrew Morton
Quoted 2 lines · On Thu, 07 Aug 2008 19:40:14 +0800 Ian Kent <[email protected]> wrote:

Patch to track the uid and gid of the last process to request a mount for on an autofs dentry.

pet peeve: changelog should not tell the reader that this is a

"patch".

Quoted 28 lines
Quoted 28 lines

Because when someone is reading the changelog in the git repository,

they hopefully already know that.

Quoted 24 lines

---

 fs/autofs4/autofs_i.h |    3 +++
 fs/autofs4/inode.c    |    2 ++
 fs/autofs4/waitq.c    |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 0 deletions(-)
fs/autofs4/autofs_i.h index renamed from fs/autofs4/autofs_i.h +0 -0

ea024d8..fa76d18 100644

fs/autofs4/autofs_i.h +3 -0
@@ -63,6 +63,9 @@ struct autofs_info {
 	unsigned long last_used;
 	atomic_t count;
 
+	uid_t uid;
+	gid_t gid;
+
 	mode_t	mode;
 	size_t	size;
 
Quoted 5 lines
Quoted 5 lines

fs/autofs4/inode.c struct autofs_info *autofs4_init_ino(struct

Quoted 5 lines
fs/autofs4/inode.c index renamed from fs/autofs4/inode.c +0 -0

9ca2d07..9408507 100644

fs/autofs4/inode.c +0 -0
@@ -53,6 +53,8 @@ struct autofs_info *autofs4_init_ino(struct

autofs_info *ino,

Quoted 22 lines
Quoted 22 lines
Quoted 13 lines
fs/autofs4/inode.c +2 -0
 		atomic_set(&ino->count, 0);
 	}
 
+	ino->uid = 0;
+	ino->gid = 0;
 	ino->mode = mode;
 	ino->last_used = jiffies;
 
fs/autofs4/waitq.c index renamed from fs/autofs4/waitq.c +0 -0

6d87bb1..7c60c0b 100644

fs/autofs4/waitq.c int autofs4_wait(struct autofs_sb_info *sbi, · line 462

Quoted 6 lines
fs/autofs4/waitq.c +2 -0
@@ -457,6 +457,40 @@ int autofs4_wait(struct autofs_sb_info *sbi, 
 struct dentry *dentry,
 
 	status = wq->status;
 
+	/*
+	 * For direct and offset mounts we need to track the requestrer

typo which I'll fix.

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
fs/autofs4/waitq.c +8 -0
+	 * uid and gid in the dentry info struct. This is so it can be
+	 * supplied, on request, by the misc device ioctl interface.
+	 * This is needed during daemon resatart when reconnecting
+	 * to existing, active, autofs mounts. The uid and gid (and
+	 * related string values) may be used for macro substitution
+	 * in autofs mount maps.
+	 */
+	if (!status) {
Quoted 8 lines

fs/autofs4/waitq.c int autofs4_wait(struct autofs_sb_info *sbi, · line 478

Quoted 8 lines
fs/autofs4/waitq.c +8 -0
+		struct autofs_info *ino;
+		struct dentry *de = NULL;
+
+		/* direct mount or browsable map */
+		ino = autofs4_dentry_ino(dentry);
+		if (!ino) {
+			/* If not lookup actual dentry used */
+			de = d_lookup(dentry->d_parent,

&dentry->d_name);

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
fs/autofs4/waitq.c +12 -0
+			if (de)
+				ino = autofs4_dentry_ino(de);
+		}
+
+		/* Set mount requester */
+		if (ino) {
+			spin_lock(&sbi->fs_lock);
+			ino->uid = wq->uid;
+			ino->gid = wq->gid;
+			spin_unlock(&sbi->fs_lock);
+		}
+
Quoted 8 lines

fs/autofs4/waitq.c int autofs4_wait(struct autofs_sb_info *sbi, · line 494

Quoted 4 lines
fs/autofs4/waitq.c +4 -0
+		if (de)
+			dput(de);
+	}
+

Please remind me again why autofs's use of current->uid and current->gid is not busted in the presence of PID namespaces, where these things are no longer system-wide unique?

Quoted 4 lines

We didn't really get to the bottom of that last time I posted this but

hopefully Serge will get right on this and we can sort out what, idf anything I need to do.

But, at this stage, I believe that if namespaces are being used then there would also need to be a daemon within the container which would have the same namespace view as other processes in the container. I expect that the situation is not nearly as straight forward as I think so I'll need to wait for further comments.

Ian

------------------------------

Message: 4
Date: Fri, 08 Aug 2008 14:12:21 +0800
From: Ian Kent <[email protected]>
Subject: Re: [autofs] [PATCH 4/4] autofs4 - add miscelaneous device
for ioctls
To: Andrew Morton <[email protected]>
Cc: [email protected], [email protected],
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain

Quoted 7 lines · Andrew Morton
Quoted 5 lines · On Fri, 08 Aug 2008 11:39:19 +0800 Ian Kent <[email protected]> wrote:
Quoted 3 lines · Andrew Morton
Quoted 1 line · On Thu, 07 Aug 2008 19:40:31 +0800 Ian Kent <[email protected]> wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Subject: [PATCH 4/4] autofs4 - add miscelaneous device for ioctls

I fixed that spello

Quoted 3 lines

Patch to add a miscellaneous device to the autofs4 module for routing ioctls. This provides the ability to obtain an ioctl file handle for an autofs mount point that is possibly covered

by another mount.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The actual problem with autofs is that it can't reconnect to existing mounts. Immediately one things of just adding the ability to remount autofs file systems would solve it, but alas,

that can't work. This is because autofs direct mounts and the implementation of "on demand mount and expire" of nested mount trees have the file system mounted on top of the mount trigger

dentry.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

To resolve this a miscellaneous device node for routing ioctl commands to these mount points has been implemented in the autofs4 kernel module and a library added to autofs. This provides the ability to open a file descriptor for these over

mounted autofs mount points.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Please refer to Documentation/filesystems/autofs4-mount-control.txt for a discussion of the problem, implementation alternatives

considered and a description of the interface.

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

...

(quoted diff) +4 -0
+
+#define AUTOFS_DEV_IOCTL_SIZE	sizeof(struct autofs_dev_ioctl)
+
+typedef int (*ioctl_fn)(struct file *, struct autofs_sb_info *,
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

+struct autofs_dev_ioctl *);

Weird layout, which I fixed.

Auuuhh .. didn't want to do this. I personally like declarations like this to be on a single line but checkpatch.pl complained about

it.

Quoted 47 lines

Well, that's why it's a checkpatch warning, not an error. The way I look at checkpatch is that it is for detecting possible mistakes. Did

you _really_ mean to do that? Usually the answer is "nope, and I wouldn't have noticed unless you told me". But sometimes the answer is "yes, I really did mean that".

I routinely ignore checkpatch 80-col warnings, unless they are flagging something which is just egregiously revolting.

Anyway, that's an aside. Given that you decided to fit that typedef into 80 cols, the way you did it was weird ;)

Quoted 33 lines
Quoted 17 lines

Review

Quoted 11 lines
(quoted diff) +10 -0
+static void autofs_dev_ioctl_fd_install(unsigned int fd, struct
 
+file *file) {
+	struct files_struct *files = current->files;
+	struct fdtable *fdt;
+
+	spin_lock(&files->file_lock);
+	fdt = files_fdtable(files);
+	rcu_assign_pointer(fdt->fd[fd], file);
+	FD_SET(fd, fdt->close_on_exec);
+	spin_unlock(&files->file_lock); }

urgh, it's bad to have done a copy-n-paste on fd_install() here. It means that if we go and change the locking in core kernel (quite
possible) then people won't udpate this code.

Quoted 8 lines

Do we have alternative here? Can we set close_on_exec outside the

lock and just call fd_install()? Probably not.

Can we export set_close_on_exec() then call that after having called fd_install()? I think so.

But not this, please.

No problem.
You mentioned this last time as well.

Since there are a couple of possible approaches and I wasn't sure which way to go I thought I'd post it as is and get feedback then make it a followup patch.

Quoted 8 lines
Quoted 2 lines

Could the pthreads user space daemon exec something between fd_install() and set_close_on_exec()?

Gee, I don't know, it would depend on the context.

Is that a private file*? Was it just created, and is there no possibility that any other thread can be sharing it anyway? If so, there's no problem.

The problem is that autofs threads can exec mount or umount at any time and we see annoying selinux file descriptor leak security violation messages. So the point of this is to set the bit at the same time as the file is inserted into the table.

Quoted 8 lines
Quoted 4 lines

Perhaps there are some other alternative approaches to this.

Suggestions?

I don't know enough about autofs nor about what problem you're attacking here to be able to say, sorry. I don't even know why close_on_exec is being set?

OK, sorry.

What I'm really after is:
Should I do this at all, given the above?
If this is sensible, should a parameter be added to fd_insall() to allow it to be requested at descriptor install or should a new function, say, fd_install_close_on_exec() be added?

Ian

------------------------------

Message: 5
Date: Thu, 7 Aug 2008 23:33:25 -0700
From: Andrew Morton <[email protected]>
Subject: Re: [autofs] [PATCH 4/4] autofs4 - add miscelaneous device
for ioctls
To: Ian Kent <[email protected]>
Cc: [email protected], [email protected],
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Quoted 27 lines · On Fri, 08 Aug 2008 14:12:21 +0800 Ian Kent <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines

No problem.
You mentioned this last time as well.

Since there are a couple of possible approaches and I wasn't sure which way to go I thought I'd post it as is and get feedback then make it a followup patch.

Quoted 8 lines
Quoted 2 lines

Could the pthreads user space daemon exec something between fd_install() and set_close_on_exec()?

Gee, I don't know, it would depend on the context.

Is that a private file*? Was it just created, and is there no possibility that any other thread can be sharing it anyway? If so, there's no problem.

The problem is that autofs threads can exec mount or umount at any time and we see annoying selinux file descriptor leak security violation messages. So the point of this is to set the bit at the same

time as the file is inserted into the table.

Quoted 5 lines
Quoted 4 lines

Perhaps there are some other alternative approaches to this.

Suggestions?

Quoted 8 lines
Quoted 3 lines

I don't know enough about autofs nor about what problem you're attacking here to be able to say, sorry. I don't even know why close_on_exec is being set?

OK, sorry.

What I'm really after is:
Should I do this at all, given the above?

I don't reliably know, sorry. <does viro summoning dance>

Quoted 4 lines

If this is sensible, should a parameter be added to fd_insall() to allow it to be requested at descriptor install or should a new function, say,
fd_install_close_on_exec() be added?

If we decide to do it this way, then we can add an extra arg to fd_install(), I guess.

void fd_install(unsigned int fd, struct file *file,

		void (*callback)(struct file *));

------------------------------

_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs

End of autofs Digest, Vol 65, Issue 7
*************************************

author
#2 lore raw
In reply to a message not in the archive

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of [email protected]
Sent: Friday, August 08, 2008 5:00 AM
To: [email protected]
Subject: autofs Digest, Vol 65, Issue 7

Send autofs mailing list submissions to
[email protected]

To subscribe or unsubscribe via the World Wide Web, visit
http://linux.kernel.org/mailman/listinfo/autofs
or, via email, send a message with subject or body 'help' to
[email protected]

You can reach the person managing the list at
[email protected]

When replying, please edit your Subject line so it is more specific than "Re: Contents of autofs digest..."

Today's Topics:

1. Re: [PATCH 2/4] autofs4 - track uid and gid of last mount requester (Ian Kent)
2. Re: [PATCH 4/4] autofs4 - add miscelaneous device for ioctls
(Andrew Morton)
3. Re: [PATCH 2/4] autofs4 - track uid and gid of last mount requester (Ian Kent)
4. Re: [PATCH 4/4] autofs4 - add miscelaneous device for ioctls
(Ian Kent)
5. Re: [PATCH 4/4] autofs4 - add miscelaneous device for ioctls
(Andrew Morton)

----------------------------------------------------------------------

Message: 1
Date: Fri, 08 Aug 2008 12:44:02 +0800
From: Ian Kent <[email protected]>
Subject: Re: [autofs] [PATCH 2/4] autofs4 - track uid and gid of last
mount requester
To: "Serge E. Hallyn" <[email protected]>
Cc: [email protected], [email protected], Andrew
Morton <[email protected]>,
[email protected],
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain

Quoted 37 lines · Ian Kent
Quoted 6 lines
Quoted 5 lines

Please remind me again why autofs's use of current->uid and current->gid is not busted in the presence of PID namespaces, current->where
these things are no longer system-wide unique?

Quoted 8 lines

I actually don't see what the autofs4_waitq->pid is used for. It's copied from current into wq->pid at autofs4_wait, and into a packet to send to userspace (I assume) at autofs4_notify_daemon.

So as long as a daemon can serve multiple pid namespaces (which doubtless it can), the pid could be confusing (or erroneous) for the

daemon.

Your point is well taken.

The pid is used purely for logging purposes to aid in debugging in user space. I'm not sure it is worth worrying about it too much as the

daemon has no business interfering with user space processes it is not

the owner of.

Quoted 5 lines

If I'm remotely right about how the pid is being used, then the thing to do would be to
1. store the daemon's pid namespace (would that belong in the autofs_sb_info?)

Yep.

Quoted 5 lines

2. store the task_pid(current) in the waitqueue
3. retrieve the pid_t for the waiting task in the daemon's pid namespace, and put that into the packet at autofs4_notify_daemon.

Quoted 5 lines
Quoted 2 lines

I realize this patch was about the *uids*, but the pids seem more urgent.

OK, I get it.
I'll have a go at doing this for completeness.

On second thoughts I'm not sure about this.

The pid that is logged needs to relate to a process in the name space of the one that caused the mount to be done.

For example, suppose a GUI user finds mounts never expiring, then we get a debug log to try and identify the culprit. So the pid should correspond to a process that the user sees (So I guess in the namespace of that user).

This is the only reason I added the pid to the request packet in the first place.

Please correct me if my understanding of this is not right.

Ian

Quoted 3 lines

Ian

------------------------------

Message: 2
Date: Thu, 7 Aug 2008 22:31:09 -0700
From: Andrew Morton <[email protected]>
Subject: Re: [autofs] [PATCH 4/4] autofs4 - add miscelaneous device
for ioctls
To: Ian Kent <[email protected]>
Cc: [email protected], [email protected],
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Quoted 5 lines · On Fri, 08 Aug 2008 11:39:19 +0800 Ian Kent <[email protected]> wrote:
Quoted 3 lines · Andrew Morton
Quoted 1 line · On Thu, 07 Aug 2008 19:40:31 +0800 Ian Kent <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Subject: [PATCH 4/4] autofs4 - add miscelaneous device for ioctls

I fixed that spello

Quoted 3 lines

Patch to add a miscellaneous device to the autofs4 module for routing ioctls. This provides the ability to obtain an ioctl file handle for an autofs mount point that is possibly covered by

another mount.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The actual problem with autofs is that it can't reconnect to existing mounts. Immediately one things of just adding the ability

to remount autofs file systems would solve it, but alas, that can't work. This is because autofs direct mounts and the implementation of "on demand mount and expire" of nested mount trees have the file system mounted on top of the mount trigger

dentry.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

To resolve this a miscellaneous device node for routing ioctl commands to these mount points has been implemented in the autofs4

kernel module and a library added to autofs. This provides the ability to open a file descriptor for these over mounted autofs

mount points.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Please refer to Documentation/filesystems/autofs4-mount-control.txt for a discussion of the problem, implementation alternatives considered

and a description of the interface.

Quoted 12 lines
Quoted 11 lines

Review

Quoted 9 lines

...

(quoted diff) +5 -0
+
+#define AUTOFS_DEV_IOCTL_SIZE	sizeof(struct autofs_dev_ioctl)
+
+typedef int (*ioctl_fn)(struct file *, struct autofs_sb_info *, 
+struct autofs_dev_ioctl *);

Weird layout, which I fixed.

Quoted 2 lines

Auuuhh .. didn't want to do this. I personally like declarations like this to be on a single line but checkpatch.pl complained about it.

Well, that's why it's a checkpatch warning, not an error. The way I look at checkpatch is that it is for detecting possible mistakes. Did you _really_ mean to do that? Usually the answer is "nope, and I wouldn't have noticed unless you told me". But sometimes the answer is "yes, I really did mean that".

I routinely ignore checkpatch 80-col warnings, unless they are flagging something which is just egregiously revolting.

Anyway, that's an aside. Given that you decided to fit that typedef into 80 cols, the way you did it was weird ;)

Quoted 29 lines
Quoted 17 lines

Review

Quoted 11 lines
(quoted diff) +11 -0
+static void autofs_dev_ioctl_fd_install(unsigned int fd, struct 
+file *file) {
+	struct files_struct *files = current->files;
+	struct fdtable *fdt;
+
+	spin_lock(&files->file_lock);
+	fdt = files_fdtable(files);
+	rcu_assign_pointer(fdt->fd[fd], file);
+	FD_SET(fd, fdt->close_on_exec);
+	spin_unlock(&files->file_lock);
+}

urgh, it's bad to have done a copy-n-paste on fd_install() here. It

means that if we go and change the locking in core kernel (quite possible) then people won't udpate this code.

Quoted 8 lines

Do we have alternative here? Can we set close_on_exec outside the lock and just call fd_install()? Probably not.

Can we export set_close_on_exec() then call that after having called

fd_install()? I think so.

But not this, please.

No problem.
You mentioned this last time as well.

Quoted 7 lines

Since there are a couple of possible approaches and I wasn't sure which way to go I thought I'd post it as is and get feedback then make

it a followup patch.

Could the pthreads user space daemon exec something between fd_install() and set_close_on_exec()?

Gee, I don't know, it would depend on the context.

Is that a private file*? Was it just created, and is there no possibility that any other thread can be sharing it anyway? If so, there's no problem.

Quoted 3 lines

Perhaps there are some other alternative approaches to this.

Suggestions?

I don't know enough about autofs nor about what problem you're attacking here to be able to say, sorry. I don't even know why close_on_exec is being set?

------------------------------

Message: 3
Date: Fri, 08 Aug 2008 13:37:41 +0800
From: Ian Kent <[email protected]>
Subject: Re: [autofs] [PATCH 2/4] autofs4 - track uid and gid of last
mount requester
To: Andrew Morton <[email protected]>
Cc: [email protected], [email protected],
[email protected], [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain

Quoted 8 lines · Ian Kent
Quoted 7 lines · Andrew Morton
Quoted 2 lines · On Thu, 07 Aug 2008 19:40:14 +0800 Ian Kent <[email protected]> wrote:

Patch to track the uid and gid of the last process to request a mount for on an autofs dentry.

pet peeve: changelog should not tell the reader that this is a

"patch".

Quoted 28 lines
Quoted 28 lines

Because when someone is reading the changelog in the git repository,

they hopefully already know that.

Quoted 24 lines

---

 fs/autofs4/autofs_i.h |    3 +++
 fs/autofs4/inode.c    |    2 ++
 fs/autofs4/waitq.c    |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 0 deletions(-)
fs/autofs4/autofs_i.h index renamed from fs/autofs4/autofs_i.h +0 -0

ea024d8..fa76d18 100644

fs/autofs4/autofs_i.h +3 -0
@@ -63,6 +63,9 @@ struct autofs_info {
 	unsigned long last_used;
 	atomic_t count;
 
+	uid_t uid;
+	gid_t gid;
+
 	mode_t	mode;
 	size_t	size;
 
Quoted 5 lines
Quoted 5 lines

fs/autofs4/inode.c struct autofs_info *autofs4_init_ino(struct

Quoted 5 lines
fs/autofs4/inode.c index renamed from fs/autofs4/inode.c +0 -0

9ca2d07..9408507 100644

fs/autofs4/inode.c +0 -0
@@ -53,6 +53,8 @@ struct autofs_info *autofs4_init_ino(struct

autofs_info *ino,

Quoted 22 lines
Quoted 22 lines
Quoted 13 lines
fs/autofs4/inode.c +2 -0
 		atomic_set(&ino->count, 0);
 	}
 
+	ino->uid = 0;
+	ino->gid = 0;
 	ino->mode = mode;
 	ino->last_used = jiffies;
 
fs/autofs4/waitq.c index renamed from fs/autofs4/waitq.c +0 -0

6d87bb1..7c60c0b 100644

fs/autofs4/waitq.c int autofs4_wait(struct autofs_sb_info *sbi, · line 462

Quoted 6 lines
fs/autofs4/waitq.c +2 -0
@@ -457,6 +457,40 @@ int autofs4_wait(struct autofs_sb_info *sbi, 
 struct dentry *dentry,
 
 	status = wq->status;
 
+	/*
+	 * For direct and offset mounts we need to track the requestrer

typo which I'll fix.

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
fs/autofs4/waitq.c +8 -0
+	 * uid and gid in the dentry info struct. This is so it can be
+	 * supplied, on request, by the misc device ioctl interface.
+	 * This is needed during daemon resatart when reconnecting
+	 * to existing, active, autofs mounts. The uid and gid (and
+	 * related string values) may be used for macro substitution
+	 * in autofs mount maps.
+	 */
+	if (!status) {
Quoted 8 lines

fs/autofs4/waitq.c int autofs4_wait(struct autofs_sb_info *sbi, · line 478

Quoted 8 lines
fs/autofs4/waitq.c +8 -0
+		struct autofs_info *ino;
+		struct dentry *de = NULL;
+
+		/* direct mount or browsable map */
+		ino = autofs4_dentry_ino(dentry);
+		if (!ino) {
+			/* If not lookup actual dentry used */
+			de = d_lookup(dentry->d_parent,

&dentry->d_name);

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
fs/autofs4/waitq.c +12 -0
+			if (de)
+				ino = autofs4_dentry_ino(de);
+		}
+
+		/* Set mount requester */
+		if (ino) {
+			spin_lock(&sbi->fs_lock);
+			ino->uid = wq->uid;
+			ino->gid = wq->gid;
+			spin_unlock(&sbi->fs_lock);
+		}
+
Quoted 8 lines

fs/autofs4/waitq.c int autofs4_wait(struct autofs_sb_info *sbi, · line 494

Quoted 4 lines
fs/autofs4/waitq.c +4 -0
+		if (de)
+			dput(de);
+	}
+

Please remind me again why autofs's use of current->uid and current->gid is not busted in the presence of PID namespaces, where these things are no longer system-wide unique?

Quoted 4 lines

We didn't really get to the bottom of that last time I posted this but

hopefully Serge will get right on this and we can sort out what, idf anything I need to do.

But, at this stage, I believe that if namespaces are being used then there would also need to be a daemon within the container which would have the same namespace view as other processes in the container. I expect that the situation is not nearly as straight forward as I think so I'll need to wait for further comments.

Ian

------------------------------

Message: 4
Date: Fri, 08 Aug 2008 14:12:21 +0800
From: Ian Kent <[email protected]>
Subject: Re: [autofs] [PATCH 4/4] autofs4 - add miscelaneous device
for ioctls
To: Andrew Morton <[email protected]>
Cc: [email protected], [email protected],
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain

Quoted 7 lines · Andrew Morton
Quoted 5 lines · On Fri, 08 Aug 2008 11:39:19 +0800 Ian Kent <[email protected]> wrote:
Quoted 3 lines · Andrew Morton
Quoted 1 line · On Thu, 07 Aug 2008 19:40:31 +0800 Ian Kent <[email protected]> wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Subject: [PATCH 4/4] autofs4 - add miscelaneous device for ioctls

I fixed that spello

Quoted 3 lines

Patch to add a miscellaneous device to the autofs4 module for routing ioctls. This provides the ability to obtain an ioctl file handle for an autofs mount point that is possibly covered

by another mount.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The actual problem with autofs is that it can't reconnect to existing mounts. Immediately one things of just adding the ability to remount autofs file systems would solve it, but alas,

that can't work. This is because autofs direct mounts and the implementation of "on demand mount and expire" of nested mount trees have the file system mounted on top of the mount trigger

dentry.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

To resolve this a miscellaneous device node for routing ioctl commands to these mount points has been implemented in the autofs4 kernel module and a library added to autofs. This provides the ability to open a file descriptor for these over

mounted autofs mount points.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Please refer to Documentation/filesystems/autofs4-mount-control.txt for a discussion of the problem, implementation alternatives

considered and a description of the interface.

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

...

(quoted diff) +4 -0
+
+#define AUTOFS_DEV_IOCTL_SIZE	sizeof(struct autofs_dev_ioctl)
+
+typedef int (*ioctl_fn)(struct file *, struct autofs_sb_info *,
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

+struct autofs_dev_ioctl *);

Weird layout, which I fixed.

Auuuhh .. didn't want to do this. I personally like declarations like this to be on a single line but checkpatch.pl complained about

it.

Quoted 47 lines

Well, that's why it's a checkpatch warning, not an error. The way I look at checkpatch is that it is for detecting possible mistakes. Did

you _really_ mean to do that? Usually the answer is "nope, and I wouldn't have noticed unless you told me". But sometimes the answer is "yes, I really did mean that".

I routinely ignore checkpatch 80-col warnings, unless they are flagging something which is just egregiously revolting.

Anyway, that's an aside. Given that you decided to fit that typedef into 80 cols, the way you did it was weird ;)

Quoted 33 lines
Quoted 17 lines

Review

Quoted 11 lines
(quoted diff) +10 -0
+static void autofs_dev_ioctl_fd_install(unsigned int fd, struct
 
+file *file) {
+	struct files_struct *files = current->files;
+	struct fdtable *fdt;
+
+	spin_lock(&files->file_lock);
+	fdt = files_fdtable(files);
+	rcu_assign_pointer(fdt->fd[fd], file);
+	FD_SET(fd, fdt->close_on_exec);
+	spin_unlock(&files->file_lock); }

urgh, it's bad to have done a copy-n-paste on fd_install() here. It means that if we go and change the locking in core kernel (quite
possible) then people won't udpate this code.

Quoted 8 lines

Do we have alternative here? Can we set close_on_exec outside the

lock and just call fd_install()? Probably not.

Can we export set_close_on_exec() then call that after having called fd_install()? I think so.

But not this, please.

No problem.
You mentioned this last time as well.

Since there are a couple of possible approaches and I wasn't sure which way to go I thought I'd post it as is and get feedback then make it a followup patch.

Quoted 8 lines
Quoted 2 lines

Could the pthreads user space daemon exec something between fd_install() and set_close_on_exec()?

Gee, I don't know, it would depend on the context.

Is that a private file*? Was it just created, and is there no possibility that any other thread can be sharing it anyway? If so, there's no problem.

The problem is that autofs threads can exec mount or umount at any time and we see annoying selinux file descriptor leak security violation messages. So the point of this is to set the bit at the same time as the file is inserted into the table.

Quoted 8 lines
Quoted 4 lines

Perhaps there are some other alternative approaches to this.

Suggestions?

I don't know enough about autofs nor about what problem you're attacking here to be able to say, sorry. I don't even know why close_on_exec is being set?

OK, sorry.

What I'm really after is:
Should I do this at all, given the above?
If this is sensible, should a parameter be added to fd_insall() to allow it to be requested at descriptor install or should a new function, say, fd_install_close_on_exec() be added?

Ian

------------------------------

Message: 5
Date: Thu, 7 Aug 2008 23:33:25 -0700
From: Andrew Morton <[email protected]>
Subject: Re: [autofs] [PATCH 4/4] autofs4 - add miscelaneous device
for ioctls
To: Ian Kent <[email protected]>
Cc: [email protected], [email protected],
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Quoted 27 lines · On Fri, 08 Aug 2008 14:12:21 +0800 Ian Kent <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines

No problem.
You mentioned this last time as well.

Since there are a couple of possible approaches and I wasn't sure which way to go I thought I'd post it as is and get feedback then make it a followup patch.

Quoted 8 lines
Quoted 2 lines

Could the pthreads user space daemon exec something between fd_install() and set_close_on_exec()?

Gee, I don't know, it would depend on the context.

Is that a private file*? Was it just created, and is there no possibility that any other thread can be sharing it anyway? If so, there's no problem.

The problem is that autofs threads can exec mount or umount at any time and we see annoying selinux file descriptor leak security violation messages. So the point of this is to set the bit at the same

time as the file is inserted into the table.

Quoted 5 lines
Quoted 4 lines

Perhaps there are some other alternative approaches to this.

Suggestions?

Quoted 8 lines
Quoted 3 lines

I don't know enough about autofs nor about what problem you're attacking here to be able to say, sorry. I don't even know why close_on_exec is being set?

OK, sorry.

What I'm really after is:
Should I do this at all, given the above?

I don't reliably know, sorry. <does viro summoning dance>

Quoted 4 lines

If this is sensible, should a parameter be added to fd_insall() to allow it to be requested at descriptor install or should a new function, say,
fd_install_close_on_exec() be added?

If we decide to do it this way, then we can add an extra arg to fd_install(), I guess.

void fd_install(unsigned int fd, struct file *file,

		void (*callback)(struct file *));

------------------------------

_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs

End of autofs Digest, Vol 65, Issue 7
*************************************