]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/ncpfs/dir.c
Don't pass inode to ->d_hash() and ->d_compare()
[karo-tx-linux.git] / fs / ncpfs / dir.c
index 3bc105d36f10f47a9fae3391b61b04dd868f7a17..3be047474bfc355731c08e2a6c27b40e73ce9e8b 100644 (file)
@@ -73,10 +73,8 @@ const struct inode_operations ncp_dir_inode_operations =
  * Dentry operations routines
  */
 static int ncp_lookup_validate(struct dentry *, unsigned int);
-static int ncp_hash_dentry(const struct dentry *, const struct inode *,
-               struct qstr *);
-static int ncp_compare_dentry(const struct dentry *, const struct inode *,
-               const struct dentry *, const struct inode *,
+static int ncp_hash_dentry(const struct dentry *, struct qstr *);
+static int ncp_compare_dentry(const struct dentry *, const struct dentry *,
                unsigned int, const char *, const struct qstr *);
 static int ncp_delete_dentry(const struct dentry *);
 
@@ -119,11 +117,19 @@ static inline int ncp_case_sensitive(const struct inode *i)
 /*
  * Note: leave the hash unchanged if the directory
  * is case-sensitive.
+ *
+ * Accessing the parent inode can be racy under RCU pathwalking.
+ * Use ACCESS_ONCE() to make sure we use _one_ particular inode,
+ * the callers will handle races.
  */
 static int 
-ncp_hash_dentry(const struct dentry *dentry, const struct inode *inode,
-               struct qstr *this)
+ncp_hash_dentry(const struct dentry *dentry, struct qstr *this)
 {
+       struct inode *inode = ACCESS_ONCE(dentry->d_inode);
+
+       if (!inode)
+               return 0;
+
        if (!ncp_case_sensitive(inode)) {
                struct super_block *sb = dentry->d_sb;
                struct nls_table *t;
@@ -140,14 +146,24 @@ ncp_hash_dentry(const struct dentry *dentry, const struct inode *inode,
        return 0;
 }
 
+/*
+ * Accessing the parent inode can be racy under RCU pathwalking.
+ * Use ACCESS_ONCE() to make sure we use _one_ particular inode,
+ * the callers will handle races.
+ */
 static int
-ncp_compare_dentry(const struct dentry *parent, const struct inode *pinode,
-               const struct dentry *dentry, const struct inode *inode,
+ncp_compare_dentry(const struct dentry *parent, const struct dentry *dentry,
                unsigned int len, const char *str, const struct qstr *name)
 {
+       struct inode *pinode;
+
        if (len != name->len)
                return 1;
 
+       pinode = ACCESS_ONCE(parent->d_inode);
+       if (!pinode)
+               return 1;
+
        if (ncp_case_sensitive(pinode))
                return strncmp(str, name->name, len);