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

From: Eric W. Biederman
Date: Sun Sep 28 2008 - 23:05:47 EST


Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> writes:

> 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.

We definitely have a race between d_kill setting dentry->d_inode = NULL
and proc_sys_compare reading d_inode.

We don't generate negative dentries for /proc/sys.

In dput atomic_dec_and_lock takes the lock before setting the count to 0.
So there is no race there.

Testing for d_unhashed and getting us out of rcu limbo before calling
into the filesystem methods makes the reasoning a lot clearer.


Looks good to me.

Reviewed-by: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/