Re: [PATCH v4 10/12] ptrace: Don't change __state
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
- Subject: Re: [PATCH v4 10/12] ptrace: Don't change __state
- From: Oleg Nesterov <oleg@xxxxxxxxxx>
- Date: Tue, 10 May 2022 16:23:18 +0200
- Cc: linux-kernel@xxxxxxxxxxxxxxx, rjw@xxxxxxxxxxxxx, mingo@xxxxxxxxxx, vincent.guittot@xxxxxxxxxx, dietmar.eggemann@xxxxxxx, rostedt@xxxxxxxxxxx, mgorman@xxxxxxx, bigeasy@xxxxxxxxxxxxx, Will Deacon <will@xxxxxxxxxx>, tj@xxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Richard Weinberger <richard@xxxxxx>, Anton Ivanov <anton.ivanov@xxxxxxxxxxxxxxxxxx>, Johannes Berg <johannes@xxxxxxxxxxxxxxxx>, linux-um@xxxxxxxxxxxxxxxxxxx, Chris Zankel <chris@xxxxxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, linux-xtensa@xxxxxxxxxxxxxxxx, Kees Cook <keescook@xxxxxxxxxxxx>, Jann Horn <jannh@xxxxxxxxxx>, linux-ia64@xxxxxxxxxxxxxxx
- In-reply-to: <20220505182645.497868-10-ebiederm@xmission.com>
- References: <87a6bv6dl6.fsf_-_@email.froward.int.ebiederm.org> <20220505182645.497868-10-ebiederm@xmission.com>
- User-agent: Mutt/1.5.24 (2015-08-30)
On 05/05, Eric W. Biederman wrote:
>
> static void ptrace_unfreeze_traced(struct task_struct *task)
> {
> - if (READ_ONCE(task->__state) != __TASK_TRACED)
> - return;
> -
> - WARN_ON(!task->ptrace || task->parent != current);
> + unsigned long flags;
>
> /*
> - * PTRACE_LISTEN can allow ptrace_trap_notify to wake us up remotely.
> - * Recheck state under the lock to close this race.
> + * The child may be awake and may have cleared
> + * JOBCTL_PTRACE_FROZEN (see ptrace_resume). The child will
> + * not set JOBCTL_PTRACE_FROZEN or enter __TASK_TRACED anew.
> */
> - spin_lock_irq(&task->sighand->siglock);
> - if (READ_ONCE(task->__state) == __TASK_TRACED) {
> + if (lock_task_sighand(task, &flags)) {
But I still think that a lockless
if (!(task->jobctl & JOBCTL_PTRACE_FROZEN))
return;
check at the start of ptrace_unfreeze_traced() makes sense to avoid
lock_task_sighand() if possible.
And ptrace_resume() can probably clear JOBCTL_PTRACE_FROZEN along with
JOBCTL_TRACED to make this optimization work better. The same for
ptrace_signal_wake_up().
Oleg.
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]