From: Linus Torvalds <torvalds@linux-foundation.org>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
viro@zeniv.linux.org.uk, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: 2.6.27-rc7-sha1: EIP at proc_sys_compare+0x36/0x50
Date: Sun, 28 Sep 2008 13:38:27 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.1.10.0809281326240.3265@nehalem.linux-foundation.org> (raw)
In-Reply-To: <m1bpyadlm0.fsf@frodo.ebiederm.org>
On Sat, 27 Sep 2008, Eric W. Biederman wrote:
>
> We hold the directory mutex in real_lookup
> before calling i_op->lookup.
Irrelevant.
The d_compare function si called _before_ we get the directory mutex. It's
done purely under dentry->dlock (and the RCU read lock).
So we have absolutely no directory-level locking here.
> So lookups should be serialized.
lookups are serialized before calling into the filesystem with ->lookup,
but _not_ at the d_compare level. If we serialized d_compare, the dentry
cache would be no use at all, we'd serialize all lookups, cached or not.
(Of course, sane filesystems will not have d_compare at all, just the
memcmp, but we're talking /proc here - although I forget why it wants to
do that insane d_compare thing)
So forget the directory mutex. d_compare is much more low-level than that.
It can hit a dentry that is being unhashed at the same time for whatever
reason (memory pressure, whatever).
The fact is, the "->lookup()" function is meant to be easy for filesystems
to use, but d_compare i really low-level dentry magic and is meant to look
at just the *name*. It's meant to be a replacement for memcpy() for things
like case-independent comparisons or strange utf-8 rules (ie "equivalent"
characters). It has no real locking, since the names are supposed to be
"stable" anyway (the dentry->d_lock should guarantee that the dentry isn't
being renamed etc).
I may be missing something, of course, but the dentry eas actually found
_before_ takign even the dentry->d_lock, so the dentry we call compare on
may not even be *valid* any more, because something might have unhashed it
_after_ we found it, but _before_ we got d_lock.
d_compare() really is pretty special (d_revalidate is too, for that
matter, although at least _slightly_ less so: by that time we have at
least tested that the UNHASHED bit isn't set because we raced with
removal etc).
Linus
next prev parent reply other threads:[~2008-09-28 20:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-26 15:20 Alexey Dobriyan
2008-09-26 15:47 ` Linus Torvalds
2008-09-27 8:44 ` Eric W. Biederman
2008-09-28 20:38 ` Linus Torvalds [this message]
2008-09-28 14:18 ` Al Viro
2008-09-28 19:28 ` Hugh Dickins
2008-09-28 20:55 ` Linus Torvalds
2008-09-28 20:59 ` Linus Torvalds
2008-09-28 22:07 ` Hugh Dickins
2008-09-29 3:05 ` Eric W. Biederman
2008-09-28 20:46 ` Linus Torvalds
2008-09-28 20:50 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.1.10.0809281326240.3265@nehalem.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome