]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
lock_parent: don't step on stale ->d_parent of all-but-freed one
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 12 Jun 2014 04:29:13 +0000 (00:29 -0400)
committerJiri Slaby <jslaby@suse.cz>
Thu, 30 Oct 2014 21:17:49 +0000 (22:17 +0100)
commit56a60dd28baa8b6e38f16d54c60370002dd690e9
tree3d6d19c371ebea6aae2ef0fc9ae971324992469a
parent3fc5a7a953bd4cbbb7e0b6c56fa3c8c91a4aa22c
lock_parent: don't step on stale ->d_parent of all-but-freed one

commit c2338f2dc7c1e9f6202f370c64ffd7f44f3d4b51 upstream.

Dentry that had been through (or into) __dentry_kill() might be seen
by shrink_dentry_list(); that's normal, it'll be taken off the shrink
list and freed if __dentry_kill() has already finished.  The problem
is, its ->d_parent might be pointing to already freed dentry, so
lock_parent() needs to be careful.

We need to check that dentry hasn't already gone into __dentry_kill()
*and* grab rcu_read_lock() before dropping ->d_lock - the latter makes
sure that whatever we see in ->d_parent after dropping ->d_lock it
won't be freed until we drop rcu_read_lock().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
fs/dcache.c