:2.4.19: do_revalidate in chown
PATCH 1/1 :2.4.19: do_revalidate in chown
Greetings,
Requesting for comments on the below findings and the patch.
sys_stat() does a do_revalidate() after user_path_walk() but sys_chown() does not. This causes sys_chown() to use incorrect attribute information on distributed file systems. The sys_stat does do_revalidate() to revalidate the inodes for proper NFS attibute caching.
But when sys_chown calls chown_common after the user_path_walk, no checks are being done regarding the dentry values, which contain cached inode values. On Distributed File system environments there may be a likelyhood that these values may not be current and there is a likelihood of stale values being read.
Hence doing a do_revalidate before the chown calls will help address this issue.
Below is a patch which does that.
Regards,
Inguva
fs-fixed/open.c Thu Sep 5 14:44:24 2002 renamed from fs/open.c Thu Sep 5 02:34:38 2002 +0 -0
@@ -20,6 +20,8 @@ #define special_file(m)
(S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
+extern int do_revalidate(struct dentry *);
+
int vfs_statfs(struct super_block *sb, struct statfs *buf) {
int retval = -ENODEV;
@@ -608,7 +610,9 @@
error = user_path_walk(filename, &nd);
if (!error) {
- error = chown_common(nd.dentry, user, group); + error = do_revalidate(nd.dentry); + if (!error)
+ error = chown_common(nd.dentry, user, group);
path_release(&nd);
}
return error;
@@ -621,7 +625,9 @@
error = user_path_walk_link(filename, &nd);
if (!error) {
- error = chown_common(nd.dentry, user, group); + error = do_revalidate(nd.dentry); + if (!error)
+ error = chown_common(nd.dentry, user, group);
path_release(&nd);
}
return error;
@@ -632,12 +638,15 @@
{
struct file * file;
int error = -EBADF;
-
- file = fget(fd);
- if (file) {
- error = chown_common(file->f_dentry, user, group);
- fput(file);
- }
+
+ if(!do_revalidate(file->f_dentry))
+ {
+ file = fget(fd);
+ if (file) {
+ error = chown_common(file->f_dentry, user, group);
+ fput(file);
+ }+ }
return error;
}
fs-fixed/stat.c Thu Sep 5 14:44:24 2002 renamed from fs/stat.c Thu Sep 5 09:59:52 2002 +2 -0
@@ -13,11 +13,12 @@ #include <asm/uaccess.h> +extern int do_revalidate(struct dentry *); + /* * Revalidate the inode. This is required for proper NFS attribute
caching.
*/
-static __inline__ int
-do_revalidate(struct dentry *dentry)
+int do_revalidate(struct dentry *dentry)
{
struct inode * inode = dentry->d_inode;
if (inode->i_op && inode->i_op->revalidate)