All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]:2.4.19: do_revalidate in chown
@ 2002-09-06  1:32 Inguva
  0 siblings, 0 replies; only message in thread
From: Inguva @ 2002-09-06  1:32 UTC (permalink / raw)
  To: linux-kernel

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)



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-09-05 12:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-06  1:32 [PATCH]:2.4.19: do_revalidate in chown Inguva

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.