public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Mounting on floating mounts is possible
@ 2004-11-06  5:04 Björn Steinbrink
  2004-11-08 16:20 ` Mike Waychison
  0 siblings, 1 reply; 4+ messages in thread
From: Björn Steinbrink @ 2004-11-06  5:04 UTC (permalink / raw)
  To: viro; +Cc: linux-kernel

Hi,

this[1] patch changed check_mnt() so that mounting on a floating mount
(i.e. one that was unmounted using MNT_DETACH and was still in use) is
possible, since we no longer check if the mountpoint is actually
reachable. The problem is that we may lose any reference to the floating
mount, but the mount on it will keep it alive, thus it will never go
away. The following patch removes the reference from the mount to its
namespace when it is unmounted lazily, so that check_mnt protects from
such mounts.

Please CC me as I'm not subscribed to the list.

Bjoern

[1] http://lwn.net/Articles/91946/

diff -uNr --minimal a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c    2004-10-31 00:41:02.000000000 +0200
+++ b/fs/namespace.c    2004-11-06 04:38:37.299013810 +0100
@@ -358,6 +358,7 @@
                } else {
                        struct nameidata old_nd;
                        detach_mnt(mnt, &old_nd);
+                       mnt->mnt_namespace = NULL;
                        spin_unlock(&vfsmount_lock);
                        path_release(&old_nd);
                }

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

* Re: [PATCH] Mounting on floating mounts is possible
  2004-11-06  5:04 [PATCH] Mounting on floating mounts is possible Björn Steinbrink
@ 2004-11-08 16:20 ` Mike Waychison
  2004-11-08 17:20   ` Björn Steinbrink
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Waychison @ 2004-11-08 16:20 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: viro, linux-kernel

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Björn Steinbrink wrote:
> Hi,
> 
> this[1] patch changed check_mnt() so that mounting on a floating mount
> (i.e. one that was unmounted using MNT_DETACH and was still in use) is
> possible, since we no longer check if the mountpoint is actually
> reachable. The problem is that we may lose any reference to the floating
> mount, but the mount on it will keep it alive, thus it will never go
> away. The following patch removes the reference from the mount to its
> namespace when it is unmounted lazily, so that check_mnt protects from
> such mounts.
> 
> Please CC me as I'm not subscribed to the list.
> 
> Bjoern
> 
> [1] http://lwn.net/Articles/91946/
> 
> diff -uNr --minimal a/fs/namespace.c b/fs/namespace.c
> --- a/fs/namespace.c    2004-10-31 00:41:02.000000000 +0200
> +++ b/fs/namespace.c    2004-11-06 04:38:37.299013810 +0100
> @@ -358,6 +358,7 @@
>                 } else {
>                         struct nameidata old_nd;
>                         detach_mnt(mnt, &old_nd);
> +                       mnt->mnt_namespace = NULL;
>                         spin_unlock(&vfsmount_lock);
>                         path_release(&old_nd);
>                 }
> -

I don't think this patch clears mnt_namespace for the root of the
umounted tree.  How about this?



- --
Mike Waychison
Sun Microsystems, Inc.
1 (650) 352-5299 voice
1 (416) 202-8336 voice

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NOTICE:  The opinions expressed in this email are held by me,
and may not represent the views of Sun Microsystems, Inc.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBj5zKdQs4kOxk3/MRAv7FAKCdtASSH1sbq8KX1Yo0IrQZJ25q9gCfUp52
Uy0LxZvoqfJ9bh5jWGv7YM4=
=pce6
-----END PGP SIGNATURE-----

[-- Attachment #2: clear_mnt_namespace.diff --]
[-- Type: text/x-patch, Size: 616 bytes --]

---

 namespace.c |    1 +
 1 files changed, 1 insertion(+)

Index: linux-2.6.9-quilt/fs/namespace.c
===================================================================
--- linux-2.6.9-quilt.orig/fs/namespace.c	2004-11-08 11:18:39.980358880 -0500
+++ linux-2.6.9-quilt/fs/namespace.c	2004-11-08 11:19:24.702560072 -0500
@@ -352,6 +352,7 @@ void umount_tree(struct vfsmount *mnt)
 		mnt = list_entry(kill.next, struct vfsmount, mnt_list);
 		list_del_init(&mnt->mnt_list);
 		list_del_init(&mnt->mnt_fslink);
+		mnt->mnt_namespace = NULL;
 		if (mnt->mnt_parent == mnt) {
 			spin_unlock(&vfsmount_lock);
 		} else {

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

* Re: [PATCH] Mounting on floating mounts is possible
  2004-11-08 16:20 ` Mike Waychison
@ 2004-11-08 17:20   ` Björn Steinbrink
  2004-11-08 17:53     ` Mike Waychison
  0 siblings, 1 reply; 4+ messages in thread
From: Björn Steinbrink @ 2004-11-08 17:20 UTC (permalink / raw)
  To: Mike Waychison; +Cc: viro, linux-kernel

On Mon, 08 Nov 2004 11:20:27 -0500
Mike Waychison <Michael.Waychison@Sun.COM> wrote:
> Björn Steinbrink wrote:
> > Hi,
> > 
> > this[1] patch changed check_mnt() so that mounting on a floating
> > mount(i.e. one that was unmounted using MNT_DETACH and was still in
> > use) is possible, since we no longer check if the mountpoint is
> > actually reachable. The problem is that we may lose any reference to
> > the floating mount, but the mount on it will keep it alive, thus it
> > will never go away. The following patch removes the reference from
> > the mount to its namespace when it is unmounted lazily, so that
> > check_mnt protects from such mounts.
> > 
> > Please CC me as I'm not subscribed to the list.
> > 
> > Bjoern
> > 
> > [1] http://lwn.net/Articles/91946/
> > 
> > diff -uNr --minimal a/fs/namespace.c b/fs/namespace.c
> > --- a/fs/namespace.c    2004-10-31 00:41:02.000000000 +0200
> > +++ b/fs/namespace.c    2004-11-06 04:38:37.299013810 +0100
> > @@ -358,6 +358,7 @@
> >                 } else {
> >                         struct nameidata old_nd;
> >                         detach_mnt(mnt, &old_nd);
> > +                       mnt->mnt_namespace = NULL;
> >                         spin_unlock(&vfsmount_lock);
> >                         path_release(&old_nd);
> >                 }
> > -
> 
> I don't think this patch clears mnt_namespace for the root of the
> umounted tree.  How about this?
> 

The root mount of the umounted tree is not detached yet, i.e. it has
mnt->mnt_parent != mnt and is detached in the else-branch, so that is
handled fine (at least my tests said so ;).
Only detached mounts and the namespace's root mount (that's the rootfs
mount IIRC) have mnt->mnt_parent==mnt. And we have two cases here:
a) already detached mount, this cannot happen. The only possibility to
get a detached mount into umount is the same we currently have with
mount, some process kept a reference and used a relative path. But
with the patch we would already bail out in check_mnt earlier in this
case.
b) root mount, is not detached so all mounts are still reachable
and can be unmounted as usual.

Please keep CC'ing me.

Bjoern

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

* Re: [PATCH] Mounting on floating mounts is possible
  2004-11-08 17:20   ` Björn Steinbrink
@ 2004-11-08 17:53     ` Mike Waychison
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Waychison @ 2004-11-08 17:53 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: viro, linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Björn Steinbrink wrote:
> On Mon, 08 Nov 2004 11:20:27 -0500
> Mike Waychison <Michael.Waychison@Sun.COM> wrote:
> 
>>Björn Steinbrink wrote:
>>
>>>Hi,
>>>
>>>this[1] patch changed check_mnt() so that mounting on a floating
>>>mount(i.e. one that was unmounted using MNT_DETACH and was still in
>>>use) is possible, since we no longer check if the mountpoint is
>>>actually reachable. The problem is that we may lose any reference to
>>>the floating mount, but the mount on it will keep it alive, thus it
>>>will never go away. The following patch removes the reference from
>>>the mount to its namespace when it is unmounted lazily, so that
>>>check_mnt protects from such mounts.
>>>
>>>Please CC me as I'm not subscribed to the list.
>>>
>>>Bjoern
>>>
>>>[1] http://lwn.net/Articles/91946/
>>>
>>>diff -uNr --minimal a/fs/namespace.c b/fs/namespace.c
>>>--- a/fs/namespace.c    2004-10-31 00:41:02.000000000 +0200
>>>+++ b/fs/namespace.c    2004-11-06 04:38:37.299013810 +0100
>>>@@ -358,6 +358,7 @@
>>>                } else {
>>>                        struct nameidata old_nd;
>>>                        detach_mnt(mnt, &old_nd);
>>>+                       mnt->mnt_namespace = NULL;
>>>                        spin_unlock(&vfsmount_lock);
>>>                        path_release(&old_nd);
>>>                }
>>>-
>>
>>I don't think this patch clears mnt_namespace for the root of the
>>umounted tree.  How about this?
>>
> 
> 
> The root mount of the umounted tree is not detached yet, i.e. it has
> mnt->mnt_parent != mnt and is detached in the else-branch, so that is
> handled fine (at least my tests said so ;).
> Only detached mounts and the namespace's root mount (that's the rootfs
> mount IIRC) have mnt->mnt_parent==mnt. And we have two cases here:
> a) already detached mount, this cannot happen. The only possibility to
> get a detached mount into umount is the same we currently have with
> mount, some process kept a reference and used a relative path. But
> with the patch we would already bail out in check_mnt earlier in this
> case.
> b) root mount, is not detached so all mounts are still reachable
> and can be unmounted as usual.
> 

Yup.  Okay, I got confused somewhere.

FWIW, the autofsng patchset I sent out a while ago I moved all the
mnt_namespace accounting into attach_mnt and detach_mnt.  It also allows
detached mounts to be trees..

- --
Mike Waychison
Sun Microsystems, Inc.
1 (650) 352-5299 voice
1 (416) 202-8336 voice

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NOTICE:  The opinions expressed in this email are held by me,
and may not represent the views of Sun Microsystems, Inc.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBj7J7dQs4kOxk3/MRAj17AJ4ye0gtvg3YxwcKKT4pMoyAtIcnmQCeIKh/
g9i4P8m94gMFR5djT9G7wYg=
=htws
-----END PGP SIGNATURE-----

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

end of thread, other threads:[~2004-11-08 18:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-06  5:04 [PATCH] Mounting on floating mounts is possible Björn Steinbrink
2004-11-08 16:20 ` Mike Waychison
2004-11-08 17:20   ` Björn Steinbrink
2004-11-08 17:53     ` Mike Waychison

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox