From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail333.us4.mandrillapp.com ([205.201.137.77]:34475 "EHLO mail333.us4.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752523AbcCAIP4 (ORCPT ); Tue, 1 Mar 2016 03:15:56 -0500 Received: from pmta03.dal05.mailchimp.com (127.0.0.1) by mail333.us4.mandrillapp.com id hql7ro174non for ; Tue, 1 Mar 2016 08:15:45 +0000 (envelope-from ) From: Subject: Patch "lock_parent: don't step on stale ->d_parent of all-but-freed one" has been added to the 3.14-stable tree To: , Cc: , Message-Id: <1456815005247152@kroah.com> Date: Tue, 01 Mar 2016 08:15:45 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled lock_parent: don't step on stale ->d_parent of all-but-freed one to the 3.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: lock_parent-don-t-step-on-stale-d_parent-of-all-but-freed-one.patch and it can be found in the queue-3.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From c2338f2dc7c1e9f6202f370c64ffd7f44f3d4b51 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 12 Jun 2014 00:29:13 -0400 Subject: lock_parent: don't step on stale ->d_parent of all-but-freed one From: Al Viro 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 Signed-off-by: Greg Kroah-Hartman --- fs/dcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/dcache.c +++ b/fs/dcache.c @@ -530,10 +530,12 @@ static inline struct dentry *lock_parent struct dentry *parent = dentry->d_parent; if (IS_ROOT(dentry)) return NULL; + if (unlikely((int)dentry->d_lockref.count < 0)) + return NULL; if (likely(spin_trylock(&parent->d_lock))) return parent; - spin_unlock(&dentry->d_lock); rcu_read_lock(); + spin_unlock(&dentry->d_lock); again: parent = ACCESS_ONCE(dentry->d_parent); spin_lock(&parent->d_lock); Patches currently in stable-queue which might be from viro@zeniv.linux.org.uk are queue-3.14/lock_parent-don-t-step-on-stale-d_parent-of-all-but-freed-one.patch queue-3.14/lift-the-already-marked-killed-case-into-shrink_dentry_list.patch queue-3.14/expand-dentry_kill-dentry-0-in-shrink_dentry_list.patch queue-3.14/bcache-fix-a-leak-in-bch_cached_dev_run.patch queue-3.14/dcache-add-missing-lockdep-annotation.patch queue-3.14/dealing-with-the-rest-of-shrink_dentry_list-livelock.patch queue-3.14/split-dentry_kill.patch queue-3.14/shrink_dentry_list-take-parent-s-d_lock-earlier.patch queue-3.14/dentry_kill-doesn-t-need-the-second-argument-now.patch