Skip to content

Commit d5426a3

Browse files
Al Virogregkh
Al Viro
authored andcommitted
make sure that __dentry_kill() always invalidates d_seq, unhashed or not
commit 4c0d7cd upstream. RCU pathwalk relies upon the assumption that anything that changes ->d_inode of a dentry will invalidate its ->d_seq. That's almost true - the one exception is that the final dput() of already unhashed dentry does *not* touch ->d_seq at all. Unhashing does, though, so for anything we'd found by RCU dcache lookup we are fine. Unfortunately, we can *start* with an unhashed dentry or jump into it. We could try and be careful in the (few) places where that could happen. Or we could just make the final dput() invalidate the damn thing, unhashed or not. The latter is much simpler and easier to backport, so let's do it that way. Reported-by: "Dae R. Jeong" <[email protected]> Cc: [email protected] Signed-off-by: Al Viro <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent abfc0ec commit d5426a3

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

fs/dcache.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,11 @@ static void dentry_unlink_inode(struct dentry * dentry)
357357
__releases(dentry->d_inode->i_lock)
358358
{
359359
struct inode *inode = dentry->d_inode;
360-
bool hashed = !d_unhashed(dentry);
361360

362-
if (hashed)
363-
raw_write_seqcount_begin(&dentry->d_seq);
361+
raw_write_seqcount_begin(&dentry->d_seq);
364362
__d_clear_type_and_inode(dentry);
365363
hlist_del_init(&dentry->d_u.d_alias);
366-
if (hashed)
367-
raw_write_seqcount_end(&dentry->d_seq);
364+
raw_write_seqcount_end(&dentry->d_seq);
368365
spin_unlock(&dentry->d_lock);
369366
spin_unlock(&inode->i_lock);
370367
if (!inode->i_nlink)

0 commit comments

Comments
 (0)