mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] umount after bad chdir
@ 2004-04-14 11:43 Hugh Dickins
  2004-04-14 12:12 ` raven
  0 siblings, 1 reply; 8+ messages in thread
From: Hugh Dickins @ 2004-04-14 11:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ian Kent, linux-kernel

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;


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

end of thread, other threads:[~2004-04-14 16:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-14 11:43 [PATCH] umount after bad chdir Hugh Dickins
2004-04-14 12:12 ` raven
2004-04-14 12:10   ` viro
2004-04-14 12:31     ` raven
2004-04-14 15:13       ` raven
2004-04-14 15:24         ` viro
2004-04-14 16:29           ` raven
2004-04-14 16:48             ` raven

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

all inboxes | Powered by JetHome®