From: Linus Torvalds Date: Fri, 15 Apr 2011 14:34:26 +0000 (-0700) Subject: vfs: fix incorrect dentry_update_name_case() BUG_ON() test X-Git-Tag: firefly_0821_release~7613^2~1614 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7ebfa57f6d307b66bb88600145afccde31016ab5;p=firefly-linux-kernel-4.4.55.git vfs: fix incorrect dentry_update_name_case() BUG_ON() test The case we should be verifying when updating the dentry name is that the _parent_ inode (the directory) semaphore is held, not the semaphore for the dentry itself. It's the directory locking that rename and readdir() etc all care about. The comment just above even says so - but then the BUG_ON() still checked the dentry inode itself. Very few people noticed, because this helper function really isn't used for very much, so you had to be using ncpfs to ever hit it. I think I should just remove the BUG_ON (the function really has just one user), but let's run with it fixed for a while before getting rid of it entirely. Reported-and-tested-by: Bongani Hlope Reported-and-tested-by: Bernd Feige Cc: Petr Vandrovec , Cc: Arnd Bergmann Cc: Christoph Hellwig Cc: Nick Piggin Signed-off-by: Linus Torvalds --- diff --git a/fs/dcache.c b/fs/dcache.c index ad25c4cec7d5..129a35730994 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2131,7 +2131,7 @@ EXPORT_SYMBOL(d_rehash); */ void dentry_update_name_case(struct dentry *dentry, struct qstr *name) { - BUG_ON(!mutex_is_locked(&dentry->d_inode->i_mutex)); + BUG_ON(!mutex_is_locked(&dentry->d_parent->d_inode->i_mutex)); BUG_ON(dentry->d_name.len != name->len); /* d_lookup gives this */ spin_lock(&dentry->d_lock);