2002-04-04 12:00:32

by Hirokazu Takahashi

[permalink] [raw]
Subject: [PATCH] [BUGFIX] racing between rmdir and rename on 2.4.18

Hello

I found a bug and fix it.

When files are moved under a directory which is just being removed,
it may cause a problem because target directory might be dead.

In function vfs_rename_other(), IS_DEADDIR(new_dir) check should
be done after double_down() like vfs_rename_dir() does.



--- linux/fs/namei.c.orig Tue Feb 26 04:38:09 2002
+++ linux/fs/namei.c Tue Apr 2 12:37:37 2002
@@ -1802,7 +1802,9 @@
DQUOT_INIT(old_dir);
DQUOT_INIT(new_dir);
double_down(&old_dir->i_zombie, &new_dir->i_zombie);
- if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
+ if (IS_DEADDIR(old_dir)||IS_DEADDIR(new_dir))
+ error = -ENOENT;
+ else if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
error = -EBUSY;
else
error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);