lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YF2UI8LFH0YaY6aJ@hirez.programming.kicks-ass.net>
Date:   Fri, 26 Mar 2021 08:58:27 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Oleg Nesterov <oleg@...hat.com>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        linux-kernel@...r.kernel.org, adobriyan@...il.com,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Ingo Molnar <mingo@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [RFC][PATCH] task_struct::state frobbing

On Thu, Mar 25, 2021 at 07:27:35PM +0100, Oleg Nesterov wrote:
> On 03/25, Peter Zijlstra wrote:
> >
> >  static void ptrace_unfreeze_traced(struct task_struct *task)
> >  {
> > -	if (task->state != __TASK_TRACED)
> > +	if (READ_ONCE(task->__state) != __TASK_TRACED)
> >  		return;
> 
> this change is correct,
> 
> > @@ -201,11 +201,11 @@ 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 (READ_ONCE(task->__state) == __TASK_TRACED) {
> 
> this too,
> 
> > @@ -240,7 +240,7 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
> >  	 */
> >  	read_lock(&tasklist_lock);
> >  	if (child->ptrace && child->parent == current) {
> > -		WARN_ON(child->state == __TASK_TRACED);
> > +		WARN_ON(task_is_traced(child));
> >  		/*
> >  		 * child->sighand can't be NULL, release_task()
> >  		 * does ptrace_unlink() before __exit_signal().
> > @@ -257,7 +257,7 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
> >  			 * ptrace_stop() changes ->state back to TASK_RUNNING,
> >  			 * so we should not worry about leaking __TASK_TRACED.
> >  			 */
> > -			WARN_ON(child->state == __TASK_TRACED);
> > +			WARN_ON(task_is_traced(child));
> 
> 
> the two above are not.
> 
> "state == __TASK_TRACED" and task_is_traced() is not the same thing.
> 
> "state == __TASK_TRACED" means that debugger changed the state from TASK_TRACED
> to __TASK_TRACED (iow, removed TASK_WAKEKILL) to ensure the tracee can not run,
> this doesn't affect task_is_traced().

Ah, my bad. I didn't expect the other bits to be relevant there,
should've read the code better. Will fix. Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ