All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Alexander Fyodorov <halcy@yandex.ru>,
	Juri Lelli <jlelli@redhat.com>,
	"Luis Claudio R. Goncalves" <lgoncalv@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-rt-users@vger.kernel.org
Subject: Re: [PATCH] ptrace: fix ptrace_unfreeze_traced() race with rt-lock
Date: Tue, 3 Nov 2020 12:37:49 +0100	[thread overview]
Message-ID: <20201103113748.GA23992@redhat.com> (raw)
In-Reply-To: <20201102174241.7llgokeh6cjzb7d3@linutronix.de>

On 11/02, Sebastian Andrzej Siewior wrote:
>
> On 2020-11-02 16:50:01 [+0100], Oleg Nesterov wrote:
> >
> >  static void ptrace_unfreeze_traced(struct task_struct *task)
> >  {
> > -	if (task->state != __TASK_TRACED)
> > -		return;
> > +	bool frozen = true;
>
> Is this okay for !PREEMPT_RT or is this considered as an important
> fast-path on !PREEMPT_RT?

I do not know how can ptrace_unfreeze_traced() check both ->state and
->saved_state lockless.

If it is possible then task_is_traced() can avoid pi_lock too?

> >  	WARN_ON(!task->ptrace || task->parent != current);
> >
> > @@ -207,12 +206,19 @@ static void ptrace_unfreeze_traced(struct task_struct *task)
> >  	 * Recheck state under the lock to close this race.
> >  	 */
> >  	spin_lock_irq(&task->sighand->siglock);
> > -	if (task->state == __TASK_TRACED) {
> > -		if (__fatal_signal_pending(task))
> > -			wake_up_state(task, __TASK_TRACED);
> > -		else
> > -			task->state = TASK_TRACED;
> > -	}
> > +
> > +	raw_spin_lock(&task->pi_lock);
>
> I think this got mentioned in the other emails but this requires irqsave
> because the above (siglock) does not disable interrupts on RT.

OK, I'll send V2 in a minute.

> This `saved_state' is only used for RT so it might make sense to avoid
> the PI-lock on non-RT.

The same is true for ptrace_freeze_traced(), we can probably add ifdef's
but I am not sure this makes sense...

Oleg.


  reply	other threads:[~2020-11-03 11:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02 15:50 [PATCH] ptrace: fix ptrace_unfreeze_traced() race with rt-lock Oleg Nesterov
2020-11-02 16:25 ` Oleg Nesterov
2020-11-02 16:34   ` Sebastian Andrzej Siewior
2020-11-02 17:01     ` Oleg Nesterov
2020-11-02 17:30       ` Sebastian Andrzej Siewior
2020-11-02 17:41         ` Oleg Nesterov
2020-11-02 18:04           ` Sebastian Andrzej Siewior
2020-11-02 17:42 ` Sebastian Andrzej Siewior
2020-11-03 11:37   ` Oleg Nesterov [this message]
2020-11-03 16:45     ` Sebastian Andrzej Siewior
2020-11-03 11:39 ` [PATCH v2] " Oleg Nesterov
2020-11-03 17:01   ` 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=20201103113748.GA23992@redhat.com \
    --to=oleg@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=halcy@yandex.ru \
    --cc=jlelli@redhat.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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.