From: Thomas Gleixner <tglx@linutronix.de>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] posix-cpu-timers: rcu_read_lock/unlock protect find_task_by_vpid call
Date: Tue, 2 Nov 2010 16:31:37 +0100 (CET) [thread overview]
Message-ID: <alpine.LFD.2.00.1011021630150.9357@localhost6.localdomain6> (raw)
In-Reply-To: <20101102135821.GA5964@swordfish.minsk.epam.com>
On Tue, 2 Nov 2010, Sergey Senozhatsky wrote:
> Commit 4221a9918e38b7494cee341dda7b7b4bb8c04bde "Add RCU check for
> find_task_by_vpid()" introduced rcu_lockdep_assert to find_task_by_pid_ns.
> Add rcu_read_lock/rcu_read_unlock to call find_task_by_vpid.
>
> Tetsuo Handa wrote:
>
> Quoting from one of posts in that thead
> http://kerneltrap.org/mailarchive/linux-kernel/2010/2/8/4536388
>
> | Usually tasklist gives enough protection, but if copy_process() fails
> | it calls free_pid() lockless and does call_rcu(delayed_put_pid().
> | This means, without rcu lock find_pid_ns() can't scan the hash table
> | safely.
We can remove the tasklist_lock while at it. rcu_read_lock is enough.
Thanks,
tglx
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
>
> ---
>
> diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
> index 6842eeb..855bc53 100644
> --- a/kernel/posix-cpu-timers.c
> +++ b/kernel/posix-cpu-timers.c
> @@ -38,11 +38,13 @@ static int check_clock(const clockid_t which_clock)
> return 0;
>
> read_lock(&tasklist_lock);
> + rcu_read_lock();
> p = find_task_by_vpid(pid);
> if (!p || !(CPUCLOCK_PERTHREAD(which_clock) ?
> same_thread_group(p, current) : thread_group_leader(p))) {
> error = -EINVAL;
> }
> + rcu_read_unlock();
> read_unlock(&tasklist_lock);
>
> return error;
> @@ -395,17 +397,21 @@ int posix_cpu_timer_create(struct k_itimer *new_timer)
> if (pid == 0) {
> p = current;
> } else {
> + rcu_read_lock();
> p = find_task_by_vpid(pid);
> if (p && !same_thread_group(p, current))
> p = NULL;
> + rcu_read_unlock();
> }
> } else {
> if (pid == 0) {
> p = current->group_leader;
> } else {
> + rcu_read_lock();
> p = find_task_by_vpid(pid);
> if (p && !thread_group_leader(p))
> p = NULL;
> + rcu_read_unlock();
> }
> }
> new_timer->it.cpu.task = p;
>
next prev parent reply other threads:[~2010-11-02 15:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-02 13:58 Sergey Senozhatsky
2010-11-02 15:31 ` Thomas Gleixner [this message]
2010-11-02 16:02 ` Sergey Senozhatsky
2010-11-02 16:04 ` Thomas Gleixner
2010-11-02 18:33 ` Oleg Nesterov
2010-11-03 10:58 ` Sergey Senozhatsky
2010-11-03 12:48 ` Oleg Nesterov
2010-11-03 16:10 ` Oleg Nesterov
2010-11-03 16:38 ` Sergey Senozhatsky
2010-11-03 16:52 ` Sergey Senozhatsky
2010-11-03 17:17 ` Oleg Nesterov
2010-11-05 15:53 ` [PATCH] posix-cpu-timers: workaround to suppress the problems with mt exec Oleg Nesterov
2010-11-08 18:14 ` Roland McGrath
2010-11-09 14:54 ` Stanislaw Gruszka
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.2.00.1011021630150.9357@localhost6.localdomain6 \
--to=tglx@linutronix.de \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=sergey.senozhatsky@gmail.com \
/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®