All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Fyodorov <halcy@yandex.ru>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
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 21:26:37 +0400	[thread overview]
Message-ID: <143271377797197@web5m.yandex.ru> (raw)
In-Reply-To: <20130829163300.GC15360@linutronix.de>

> +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.

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).

  reply	other threads:[~2013-08-29 17:26 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 [this message]
2013-08-29 18:28             ` Sebastian Andrzej Siewior
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=143271377797197@web5m.yandex.ru \
    --to=halcy@yandex.ru \
    --cc=bigeasy@linutronix.de \
    --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.