From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Alexander Fyodorov <halcy@yandex.ru>
Cc: "linux-rt-users@vger.kernel.org" <linux-rt-users@vger.kernel.org>
Subject: Re: [PATCH rt] Fix races in ptrace
Date: Thu, 29 Aug 2013 20:28:41 +0200 [thread overview]
Message-ID: <521F92D9.5090701@linutronix.de> (raw)
In-Reply-To: <143271377797197@web5m.yandex.ru>
On 08/29/2013 07:26 PM, Alexander Fyodorov wrote:
>> +static inline bool task_is_traced(struct task_struct *task)
>> +{
>> + bool traced = false;
>> +
>> + if (task->state & __TASK_TRACED)
>> + return true;
>> +#ifdef CONFIG_PREEMPT_RT_FULL
>> + /* in case the task is sleeping on tasklist_lock */
>> + raw_spin_lock_irq(&task->pi_lock);
>> + if (task->state & __TASK_TRACED)
>> + traced = true;
>> + else if (task->saved_state & __TASK_TRACED)
>> + traced = true;
>> + raw_spin_unlock_irq(&task->pi_lock);
>> +#endif
>> + return traced;
>> +}
>
> Since this is a low-level function, maybe its better to use raw_spin_lock_irqsave()? In case someone in the future will call task_is_traced() with disabled interrupts. Otherwise looks good.
The other function around don't do this and excpect it process context.
Thanks so far.
>
> Still this is only half of the solution because the patch doesn't solve the race in wait_task_inactive() (and all other places which test both state and saved_state without holding pi_lock).
So you are concerned that missing pi_lock in wait_task_inactive(). This
is a problem if the task wakes up from sleeping on the lock while its
state is beeing checked. Hmm it indeed looks legal.
I keep that patch in queue but disabled and take another look once I
get back.
Does this missing pi_lock() affects you or is just a precaution?
>
Sebastian
next prev parent reply other threads:[~2013-08-29 18:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-24 16:23 [PATCH rt] Fix races in ptrace Alexander Fyodorov
2013-08-12 16:41 ` Sebastian Andrzej Siewior
2013-08-12 21:13 ` Alexander Fyodorov
2013-08-21 17:24 ` Sebastian Andrzej Siewior
2013-08-22 14:23 ` Alexander Fyodorov
2013-08-29 16:33 ` Sebastian Andrzej Siewior
2013-08-29 17:26 ` Alexander Fyodorov
2013-08-29 18:28 ` Sebastian Andrzej Siewior [this message]
2013-08-29 18:47 ` Alexander Fyodorov
2013-08-29 18:49 ` Sebastian Andrzej Siewior
2013-11-30 20:07 ` [PATCH v2] ptrace: fix ptrace vs tasklist_lock race Sebastian Andrzej Siewior
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=521F92D9.5090701@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=halcy@yandex.ru \
--cc=linux-rt-users@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.