From: Jiri Olsa <jolsa@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Howells <dhowells@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Eric Dumazet <eric.dumazet@gmail.com>,
linux-kernel@vger.kernel.org,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH] cred - synchronize rcu before releasing cred
Date: Wed, 28 Jul 2010 10:25:54 +0200 [thread overview]
Message-ID: <20100728082554.GA6391@jolsa.Belkin> (raw)
In-Reply-To: <AANLkTikB9Msot4m_oaw+V+dvEg+SzyXHb0cqhKQqUtC2@mail.gmail.com>
On Tue, Jul 27, 2010 at 10:56:20AM -0700, Linus Torvalds wrote:
> On Tue, Jul 27, 2010 at 9:46 AM, David Howells <dhowells@redhat.com> wrote:
> >
> > That's not the problem.
> >
> > The problem is that task_state() accesses the target task's credentials whilst
> > only holding the RCU read lock. That means that the existence of the cred
> > struct so accessed can only be guaranteed up to the point that the RCU read
> > lock is released.
>
> Umm. In that case, get_task_cred() is actively misleading.
>
> What you are saying is that you cannot do
>
> rcu_read_lock()
> __cred = (struct cred *) __task_cred((task));
> get_cred(__cred);
> rcu_read_unlock();
>
> but that is _exactly_ what get_task_cred() does. And that
right, get_task_cred looks like source for similar bugs.. will check
> __task_cred() check checks that we have
>
> rcu_read_lock_held() || lockdep_tasklist_lock_is_held()
>
> and what you are describing would require us to have a '&&' rather
> than a '||' in that test. Because it is _not_ sufficient to have just
> the rcu_read_lock held.
>
> So it looks like the validation is simply wrong. The __task_cred()
> helper is buggy. It's used for two different cases, and they have
> totally different locking requirements.
>
> Case #1:
> - you can do __task_cred() with just read-lock held, but then you
> cannot add refs to it
>
> Case #2:
> - you can do __task_cred() with read-lock held _and_ guaranteeing
> that the task doesn't go away, and then you can hold a ref to it as
> long as you still guarantee the task is around.
>
> And the comments are actively wrong. The comments talk about the "case
> #2" thing only. Ignoring case #1, except for the fact that the _check_
> allows case #1, so you never get a warning from the RCU "proving" code
> even for incorrect code.
>
> So presumably Jiri's patch is correct, but the reason the bug happened
> in the first place is that all those accessor functions are totally
> confused about how they supposed to be used, with incorrect comments
> and incorrect access checks.
>
> That should get fixed. Who knows how many other buggy users there are
> due to the confusion?
I'll see if I can find some other places
thanks,
jirka
next prev parent reply other threads:[~2010-07-28 8:26 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-27 15:50 Jiri Olsa
2010-07-27 16:16 ` Linus Torvalds
2010-07-27 16:46 ` David Howells
2010-07-27 17:56 ` Linus Torvalds
2010-07-28 8:25 ` Jiri Olsa [this message]
2010-07-28 12:07 ` David Howells
2010-07-28 12:47 ` David Howells
2010-07-29 6:00 ` Paul E. McKenney
2010-07-29 8:34 ` David Howells
2010-07-30 21:32 ` Paul E. McKenney
2010-07-28 13:17 ` David Howells
2010-07-28 14:46 ` Jiri Olsa
2010-07-29 9:38 ` Jiri Olsa
2010-07-28 15:51 ` Linus Torvalds
-- strict thread matches above, loose matches on Subject: below --
2010-06-25 13:33 Jiri Olsa
2010-07-02 12:14 ` Jiri Olsa
2010-06-16 12:24 Jiri Olsa
2010-06-16 12:45 ` Eric Dumazet
2010-06-16 12:57 ` Jiri Olsa
2010-06-16 13:10 ` Eric Dumazet
2010-06-16 16:08 ` Jiri Olsa
2010-06-17 23:50 ` David Howells
2010-06-19 12:01 ` Jiri Olsa
2010-06-25 12:55 ` Jiri Olsa
2010-06-25 13:28 ` David Howells
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=20100728082554.GA6391@jolsa.Belkin \
--to=jolsa@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=torvalds@linux-foundation.org \
/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
all inboxes | Powered by JetHome®