Skip to contentSkip to conversation

r/o bind mount fixes for 2.6.23-mm1

PATCH In review Jan Blunck 3 participants 6 messages Oct 12, 2007 – Oct 13, 2007

Subsystems (3)
lore
Share & tools
lore

Jan Blunck

author
#0 lore raw

cover r/o bind mount fixes for 2.6.23-mm1

Here are two small patches for 2.6.23-mm1 that fix some issues with the r/o bind mount code. Besides that, I can see that you handle files opened by dentry_open() somewhere. Nevertheless this files are also fput'ed later.

Regards,
Jan

author
#1 lore raw

PATCH 1/2 r/o bind mounts: Dont touch the vfsmount after path_put()

mnt_drop_write() is called after releasing the reference to the path with path_put().

---
 net/unix/af_unix.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/unix/af_unix.c +1 -1
Index: b/net/unix/af_unix.c
===================================================================
@@ -752,8 +752,8 @@ static struct sock *unix_find_other(stru
 		if (u->sk_type == type)
 			touch_atime(nd.path.mnt, nd.path.dentry);
 
-		path_put(&nd.path);
 		mnt_drop_write(nd.path.mnt);
+		path_put(&nd.path);
 
 		err=-EPROTOTYPE;
 		if (u->sk_type != type) {
Acked-by on v1 1/2
#2 lore raw

Re: [patch 1/2] r/o bind mounts: Dont touch the vfsmount after path_put()

Quoted 5 lines · Jan Blunck

plain text document attachment (vfs)
mnt_drop_write() is called after releasing the reference to the path with path_put().

Ugh. Yeah. Thanks for finding that.

-- Dave

author
#3 lore raw

PATCH 2/2 r/o bind mounts: Accept passing a mnt NULL pointer to mnt_drop_write()

In reply to Jan Blunck

In case of somebody opens a file with dentry_open(dentry, NULL, ...) we don't want to stumble on the NULL pointer mnt in struct file.

---
 fs/namespace.c |    3 +++
 1 file changed, 3 insertions(+)
fs/namespace.c +3 -0
Index: b/fs/namespace.c
===================================================================
@@ -253,6 +253,9 @@ void mnt_drop_write(struct vfsmount *mnt
 	int must_check_underflow = 0;
 	struct mnt_writer *cpu_writer;
 
+	if (!mnt)
+		return;
+
 	cpu_writer = &get_cpu_var(mnt_writers);
 	spin_lock(&cpu_writer->lock);
 
#4 lore raw

Re: [patch 2/2] r/o bind mounts: Accept passing a mnt NULL pointer to mnt_drop_write()

Quoted 2 lines · Jan Blunck

In case of somebody opens a file with dentry_open(dentry, NULL, ...) we don't want to stumble on the NULL pointer mnt in struct file.

...

fs/namespace.c void mnt_drop_write(struct vfsmount *mnt · line 257

Quoted 7 lines

+++ b/fs/namespace.c

fs/namespace.c +2 -0
@@ -253,6 +253,9 @@ void mnt_drop_write(struct vfsmount *mnt
        int must_check_underflow = 0;
        struct mnt_writer *cpu_writer;
 
+       if (!mnt)
+               return;

I kinda wish we'd fix these in the callers. I know we do something similar to this with mntput(), but I worry a bit that this just discourages people from using the right interfaces.

Do you have a case where we're actually getting a NULL mount in here? We had at least one in reiser4 that really revealed some nastiness in the fs that needed fixing.

-- Dave

#5 lore raw

Re: [patch 2/2] r/o bind mounts: Accept passing a mnt NULL pointer to mnt_drop_write()

In reply to Jan Blunck
Quoted 2 lines · Jan Blunck

In case of somebody opens a file with dentry_open(dentry, NULL, ...) we don't want to stumble on the NULL pointer mnt in struct file.

We should just not allow a NULL vfsmount in dentry_open. Dave and I have fixes for reiserfs, and I'll look at the uml use.