Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Sunday, September 28, 2008 - 1:55 pm

On Sun, 28 Sep 2008, Hugh Dickins wrote:

Ok, you were definitely under memory pressure, and yes, it looks like the 
exact same bug on ppc64 - access to a pointer that is two poointers offset 
down from NULL.


Yes. 


I actually like my second patch better - it looks simpler, and it means 
that the rules for filesystems using d_compare() are a bit clearer: at 
least we'll only pass them dentries to look at that haven't gone through 
d_drop (and we do hold dentry->d_lock that serializes all of that).

So here it is again (I sent it out just minutes ago, but you weren't on 
that cc, you must have picked this up off the kernel list)

NOTE! Totally untested patch! It looks sane and really obvious, but maybe 
it has some insane and non-obvious bug.

		Linus

---
 fs/dcache.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 80e9395..e7a1a99 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1395,6 +1395,10 @@ struct dentry * __d_lookup(struct dentry * parent, struct qstr * name)
 		if (dentry->d_parent != parent)
 			goto next;
 
+		/* non-existing due to RCU? */
+		if (d_unhashed(dentry))
+			goto next;
+
 		/*
 		 * It is safe to compare names since d_move() cannot
 		 * change the qstr (protected by d_lock).
@@ -1410,10 +1414,8 @@ struct dentry * __d_lookup(struct dentry * parent, struct qstr * name)
 				goto next;
 		}
 
-		if (!d_unhashed(dentry)) {
-			atomic_inc(&dentry->d_count);
-			found = dentry;
-		}
+		atomic_inc(&dentry->d_count);
+		found = dentry;
 		spin_unlock(&dentry->d_lock);
 		break;
 next:
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Alexey Dobriyan, (Fri Sep 26, 8:20 am)
Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Linus Torvalds, (Fri Sep 26, 8:47 am)
Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Eric W. Biederman, (Sat Sep 27, 1:44 am)
Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Hugh Dickins, (Sun Sep 28, 12:28 pm)
Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Linus Torvalds, (Sun Sep 28, 1:38 pm)
Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Linus Torvalds, (Sun Sep 28, 1:46 pm)
Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Linus Torvalds, (Sun Sep 28, 1:50 pm)
Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Linus Torvalds, (Sun Sep 28, 1:55 pm)
Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Linus Torvalds, (Sun Sep 28, 1:59 pm)
Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Hugh Dickins, (Sun Sep 28, 3:07 pm)
Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50, Eric W. Biederman, (Sun Sep 28, 8:05 pm)