All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH vfs/for-next] fs/dcache.c: fix NULL pointer dereference in shrink_lock_dentry()
@ 2018-03-23 23:04 Eric Biggers
  2018-03-24  4:37 ` Matthew Wilcox
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Biggers @ 2018-03-23 23:04 UTC (permalink / raw)
  To: Alexander Viro, linux-fsdevel; +Cc: John Ogness, Eric Biggers

From: Eric Biggers <ebiggers@google.com>

We can reach 'out:' with a negative dentry, e.g. if there is contention
on ->d_parent->d_lock and another task concurrently gets a reference to
the negative dentry.  In that case 'inode' will be NULL, so we must not
try to unlock 'inode'.

This bug was found by xfstest generic/429.

Fixes: 121a8e083486 ("get rid of trylock loop in locking dentries on shrink list")
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/dcache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 0c78ef4bb5e7..c159a4b304cf 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1028,7 +1028,8 @@ static bool shrink_lock_dentry(struct dentry *dentry)
 		return true;
 	spin_unlock(&parent->d_lock);
 out:
-	spin_unlock(&inode->i_lock);
+	if (inode)
+		spin_unlock(&inode->i_lock);
 	return false;
 }
 
-- 
2.17.0.rc0.231.g781580f067-goog

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-24 11:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-23 23:04 [PATCH vfs/for-next] fs/dcache.c: fix NULL pointer dereference in shrink_lock_dentry() Eric Biggers
2018-03-24  4:37 ` Matthew Wilcox
2018-03-24  4:50   ` Al Viro
2018-03-24 11:35     ` Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.