Re: bug: mount on an open directory succeeds

From: V Ganesh (ganesh@veritas.com)
Date: Mon Mar 06 2000 - 04:40:09 EST


> On Mon, 06 Mar 2000, Alexander Viro wrote:
> > On Mon, 6 Mar 2000, Amit S. Kale wrote:
> >
> > > Hi,
> > > mount on an open directory succeeds.
> >
> > Yes, it does. WTF makes you think that it's a bug?

it's a feature, right. but a buggy one. RTFmail a few more lines
and you'll see why.
the problem is in lookup_dentry()
if a process looks up "." on a mounted directory and it was inside it before
the mount, then
...
                dentry = reserved_lookup(base, &this);

dentry = pwd of this process, the old (covered) /mnt.

                if (!dentry) {
                        dentry = cached_lookup(base, &this, flags);
                        if (!dentry) {
                                dentry = real_lookup(base, &this, flags);
                                if (IS_ERR(dentry))
                                        break;
                        }
                }

                /* Check mountpoints.. */
                dentry = follow_mount(dentry);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and now it's the new (mounted) /mnt.
so ls . will show you the mounted directory, but ls -l fails because
it's trying to stat files of the mounted directory in the covered directory.

I've appended a tentative fix below, need to check it. look ok ?

ganesh

--- linux/fs/namei.c.ORG Mon Mar 6 17:10:05 2000
+++ linux/fs/namei.c Mon Mar 6 17:10:48 2000
@@ -403,10 +403,9 @@
                                 if (IS_ERR(dentry))
                                         break;
                         }
+ /* Check mountpoints.. */
+ dentry = follow_mount(dentry);
                 }
-
- /* Check mountpoints.. */
- dentry = follow_mount(dentry);
 
                 base = do_follow_link(base, dentry, flags);
                 if (IS_ERR(base))

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Mar 07 2000 - 21:00:19 EST