Skip to content

Commit

Permalink
[PATCH] autofs4: fix race in unhashed dentry code
Browse files Browse the repository at this point in the history
Commit f50b6f8 introduced a race in
autofs4 between autofs_lookup_unhashed() and autofs_dentry_release().

autofs_dentry_release() ends up clearing the ->dentry and ->inode members
of autofs_info before removing it from the rehash list.  The list is
protected by the rehash lock in both functions, but since
autofs_dentry_release() starts tearing the autofs_info struct down before
removing it from the list, autofs_lookup_unhashed() can get a autofs_info
with a NULL dentry.

This patch moves the clearing of ->dentry and ->inode after the removal
from the rehash list.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Acked-by: Ian Kent <raven@themaw.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jeff Mahoney authored and Linus Torvalds committed Apr 12, 2007
1 parent 6d205f1 commit c3724b1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,16 @@ void autofs4_dentry_release(struct dentry *de)
if (inf) {
struct autofs_sb_info *sbi = autofs4_sbi(de->d_sb);

inf->dentry = NULL;
inf->inode = NULL;

if (sbi) {
spin_lock(&sbi->rehash_lock);
if (!list_empty(&inf->rehash))
list_del(&inf->rehash);
spin_unlock(&sbi->rehash_lock);
}

inf->dentry = NULL;
inf->inode = NULL;

autofs4_free_ino(inf);
}
}
Expand Down

0 comments on commit c3724b1

Please sign in to comment.