From: Michel Lespinasse Date: Tue, 27 Mar 2012 00:32:44 +0000 (-0700) Subject: vfs: fix d_ancestor() case in d_materialize_unique X-Git-Tag: v2.6.39-400.9.0~426^2~14^2~17 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f5cfabe28a5f3bd9bbda5c622fdcea874a29ec5a;p=users%2Fjedix%2Flinux-maple.git vfs: fix d_ancestor() case in d_materialize_unique commit b18dafc86bb879d2f38a1743985d7ceb283c2f4d upstream. In d_materialise_unique() there are 3 subcases to the 'aliased dentry' case; in two subcases the inode i_lock is properly released but this does not occur in the -ELOOP subcase. This seems to have been introduced by commit 1836750115f2 ("fix loop checks in d_materialise_unique()"). Signed-off-by: Michel Lespinasse [ Added a comment, and moved the unlock to where we generate the -ELOOP, which seems to be more natural. You probably can't actually trigger this without a buggy network file server - d_materialize_unique() is for finding aliases on non-local filesystems, and the d_ancestor() case is for a hardlinked directory loop. But we should be robust in the case of such buggy servers anyway. ] Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/dcache.c b/fs/dcache.c index d2f8feb75da1..64d9584f2c5d 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2427,6 +2427,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode) if (d_ancestor(alias, dentry)) { /* Check for loops */ actual = ERR_PTR(-ELOOP); + spin_unlock(&inode->i_lock); } else if (IS_ROOT(alias)) { /* Is this an anonymous mountpoint that we * could splice into our tree? */ @@ -2436,7 +2437,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode) goto found; } else { /* Nope, but we must(!) avoid directory - * aliasing */ + * aliasing. This drops inode->i_lock */ actual = __d_unalias(inode, dentry, alias); } write_sequnlock(&rename_lock);