make sure that __dentry_kill() always invalidates d_seq, unhashed or not
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 9 Aug 2018 14:15:54 +0000 (10:15 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Aug 2018 16:12:48 +0000 (18:12 +0200)
commitd5426a384144e8e28730a22ccc7bcb71d22304a7
treebb45febb3489c5d3e5ed4cb4c46e413efbf78b4b
parentabfc0ec698fc8e4407069e0c2ef79c4f20680ee4
make sure that __dentry_kill() always invalidates d_seq, unhashed or not

commit 4c0d7cd5c8416b1ef41534d19163cb07ffaa03ab 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" <threeearcat@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/dcache.c