Commit 7ebfa57f authored by Linus Torvalds's avatar Linus Torvalds

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: default avatarBongani Hlope <bonganih@bankservafrica.com>
Reported-and-tested-by: default avatarBernd Feige <bernd.feige@uniklinik-freiburg.de>
Cc: Petr Vandrovec <petr@vandrovec.name>,
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Nick Piggin <npiggin@kernel.dk>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e38f5b74
...@@ -2131,7 +2131,7 @@ EXPORT_SYMBOL(d_rehash); ...@@ -2131,7 +2131,7 @@ EXPORT_SYMBOL(d_rehash);
*/ */
void dentry_update_name_case(struct dentry *dentry, struct qstr *name) 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 */ BUG_ON(dentry->d_name.len != name->len); /* d_lookup gives this */
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment