[PATCH]:2.4.19: do_revalidate in chown

From: Inguva (inguva@softhome.net)
Date: Thu Sep 05 2002 - 20:32:20 EST


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

diff -urN ./fs/open.c ./fs-fixed/open.c
--- ./fs/open.c Thu Sep 5 02:34:38 2002
+++ ./fs-fixed/open.c Thu Sep 5 14:44:24 2002
@@ -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;
 }

diff -urN ./fs/stat.c ./fs-fixed/stat.c
--- ./fs/stat.c Thu Sep 5 09:59:52 2002
+++ ./fs-fixed/stat.c Thu Sep 5 14:44:24 2002
@@ -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)

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



This archive was generated by hypermail 2b29 : Sat Sep 07 2002 - 22:00:24 EST