From: Oleg Nesterov <oleg@redhat.com>
To: David Howells <dhowells@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
paulmck@linux.vnet.ibm.com, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
Jiri Olsa <jolsa@redhat.com>, Roland McGrath <roland@redhat.com>
Subject: Re: [PATCH 2/2] CRED: Fix __task_cred()'s lockdep check and banner comment
Date: Wed, 4 Aug 2010 17:08:05 +0200 [thread overview]
Message-ID: <20100804150805.GA5634@redhat.com> (raw)
In-Reply-To: <23577.1280930470@redhat.com>
On 08/04, David Howells wrote:
>
> Oleg Nesterov <oleg@redhat.com> wrote:
>
> > On 08/03, Linus Torvalds wrote:
> > >
> > > On Tue, Aug 3, 2010 at 2:34 AM, David Howells <dhowells@redhat.com> wrote:
> > > >
> > > > A previous patch:
> > > >
> > > > commit 8f92054e7ca1d3a3ae50fb42d2253ac8730d9b2a
> > > > Author: David Howells <dhowells@redhat.com>
> > > > Date: Thu Jul 29 12:45:55 2010 +0100
> > > > Subject: CRED: Fix __task_cred()'s lockdep check and banner comment
> >
> > I am not sure I understand this patch.
>
> You are talking about the 'previous patch'?
>
> > __task_cred() checks rcu_read_lock_held() || task_is_dead(), and
> > task_is_dead(task) is ((task)->exit_state != 0).
> >
> > OK, task_is_dead() is valid for, say, wait_task_zombie(). But
> > wait_task_stopped() calls __task_cred(p) without rcu lock and p is alive.
> > The code is correct, this thread can do nothing until we drop ->siglock.
>
> The problem is that we have to tell lockdep this. Just checking in
> __task_cred() that siglock is held is insufficient. That doesn't handle, say,
> sys_setuid() from changing the credentials, and effectively skips the check in
> places where it mustn't.
>
> Similarly, having interrupts disabled on the CPU we're running on doesn't help
> either, since it doesn't stop another CPU replacing those credentials.
>
> There are ways of dealing with wait_task_stopped():
>
> (1) Place an rcu_read_lock()'d section around the call to __task_cred().
Sure, this solves the problem. But probably this needs a comment to
explain why do we take rcu lock.
OTOH, wait_task_continued() does need rcu_read_lock(), the task is running.
UNLESS we believe that local_irq_disable() makes rcu_read_lock() unnecessary,
see below.
> (2) Make __task_cred()'s lockdep understand about the target task being
> stopped whilst we hold its siglock.
May be... but we have so many special cases. Say, fill_psinfo()->__task_cred().
This is called under rcu lock, but it is not needed. The task is either
current or it sleeps in exit_mm().
I mean, perhaps it is better to either always require rcu_read_lock()
around __task_cred() even if it is not needed, or do not use
rcu_dereference_check() at all.
In any case, task_is_dead() doesn't help afaics, it is only useful for
wait_task_zombie().
> > I must admit, at first glance changing check_kill_permission() to take
> > rcu lock looks better to me.
>
> I think group_send_sig_info() would be better. The only other caller of
> c_k_p() already has to hold the RCU read lock for other reasons.
>
> How about the attached patch then?
Agreed, the patch looks fine to me.
> > > > On the other hand, some of the callers are either holding the RCU read
> > > > lock already, or have disabled interrupts,
> >
> > Hmm. So, local_irq_disable() "officially" blocks rcu? It does in practice
> > (unless I missed the new version of RCU), but, say, posix_timer_event()
> > takes rcu_read_lock() exactly because I thought we shouldn't assume that
> > irqs_disabled() acts as rcu_read_lock() ?
>
> This CPU can't be preempted if it can't be interrupted, I think.
Yes, please note "It does in practice" above.
My question is, should/can we rely on this fact? Or should we assume
that nothing except rcu_read_lock() implies rcu_read_lock() ?
Oleg.
next prev parent reply other threads:[~2010-08-04 15:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-29 11:45 [PATCH 1/2] CRED: Fix get_task_cred() and task_state() to not resurrect dead credentials David Howells
2010-07-29 11:45 ` [PATCH 2/2] CRED: Fix __task_cred()'s lockdep check and banner comment David Howells
2010-08-02 20:40 ` Paul E. McKenney
2010-08-03 0:55 ` Tetsuo Handa
2010-08-03 9:34 ` David Howells
2010-08-03 16:07 ` Linus Torvalds
2010-08-03 17:48 ` Thomas Gleixner
2010-08-04 13:17 ` Oleg Nesterov
2010-08-04 14:01 ` David Howells
2010-08-04 15:08 ` Oleg Nesterov [this message]
2010-08-04 15:22 ` David Howells
2010-08-04 15:44 ` Oleg Nesterov
2010-08-05 7:19 ` Eric W. Biederman
2010-08-05 16:14 ` Linus Torvalds
2010-08-05 18:16 ` Oleg Nesterov
2010-08-05 20:13 ` Eric W. Biederman
2010-08-05 20:26 ` Linus Torvalds
2010-08-05 21:20 ` Eric W. Biederman
2010-08-04 0:38 ` Tetsuo Handa
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=20100804150805.GA5634@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=roland@redhat.com \
--cc=tglx@linutronix.de \
--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