[PATCH] umount after bad chdir

From: Hugh Dickins
Date: Wed Apr 14 2004 - 06:45:59 EST


After chdir (or chroot) to non-existent directory on 2.6.5-mm5, you
can no longer unmount filesystem holding working directory (or root).

--- 2.6.5-mm5/fs/open.c 2004-04-13 11:02:25.000000000 +0100
+++ linux/fs/open.c 2004-04-14 12:23:26.633056368 +0100
@@ -517,13 +517,16 @@ asmlinkage long sys_chdir(const char __u
{
struct nameidata nd;
int error;
- struct vfsmount *old_mnt = mntget(current->fs->pwdmnt);
- struct dentry *old_dentry = dget(current->fs->pwd);
+ struct vfsmount *old_mnt;
+ struct dentry *old_dentry;

error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
if (error)
goto out;

+ old_mnt = mntget(current->fs->pwdmnt);
+ old_dentry = dget(current->fs->pwd);
+
error = permission(nd.dentry->d_inode,MAY_EXEC,&nd);
if (error)
goto dput_and_out;
@@ -590,13 +593,16 @@ asmlinkage long sys_chroot(const char __
{
struct nameidata nd;
int error;
- struct vfsmount *old_mnt = mntget(current->fs->rootmnt);
- struct dentry *old_dentry = dget(current->fs->root);
+ struct vfsmount *old_mnt;
+ struct dentry *old_dentry;

error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
if (error)
goto out;

+ old_mnt = mntget(current->fs->pwdmnt);
+ old_dentry = dget(current->fs->pwd);
+
error = permission(nd.dentry->d_inode,MAY_EXEC,&nd);
if (error)
goto dput_and_out;

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