From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9771C433EF for ; Tue, 28 Jun 2022 22:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229558AbiF1Ws5 (ORCPT ); Tue, 28 Jun 2022 18:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiF1Ws4 (ORCPT ); Tue, 28 Jun 2022 18:48:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C3113A709; Tue, 28 Jun 2022 15:48:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 20E6761AC0; Tue, 28 Jun 2022 22:48:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAE46C341C8; Tue, 28 Jun 2022 22:48:51 +0000 (UTC) Date: Tue, 28 Jun 2022 18:48:50 -0400 From: Steven Rostedt To: "Eric W. Biederman" Cc: Alexander Gordeev , linux-kernel@vger.kernel.org, rjw@rjwysocki.net, Oleg Nesterov , mingo@kernel.org, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, mgorman@suse.de, bigeasy@linutronix.de, Will Deacon , tj@kernel.org, linux-pm@vger.kernel.org, Peter Zijlstra , Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org, Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org Subject: Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state Message-ID: <20220628184850.05f60d1e@gandalf.local.home> In-Reply-To: <87czess94h.fsf@email.froward.int.ebiederm.org> References: <87a6bv6dl6.fsf_-_@email.froward.int.ebiederm.org> <20220505182645.497868-12-ebiederm@xmission.com> <877d5ajesi.fsf@email.froward.int.ebiederm.org> <87y1xk8zx5.fsf@email.froward.int.ebiederm.org> <87czess94h.fsf@email.froward.int.ebiederm.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Tue, 28 Jun 2022 17:42:22 -0500 "Eric W. Biederman" wrote: > diff --git a/kernel/ptrace.c b/kernel/ptrace.c > index 156a99283b11..cb85bcf84640 100644 > --- a/kernel/ptrace.c > +++ b/kernel/ptrace.c > @@ -202,6 +202,7 @@ static bool ptrace_freeze_traced(struct task_struct *task) > spin_lock_irq(&task->sighand->siglock); > if (task_is_traced(task) && !looks_like_a_spurious_pid(task) && > !__fatal_signal_pending(task)) { > + smp_rmb(); > task->jobctl |= JOBCTL_PTRACE_FROZEN; > ret = true; > } > diff --git a/kernel/signal.c b/kernel/signal.c > index edb1dc9b00dc..bcd576e9de66 100644 > --- a/kernel/signal.c > +++ b/kernel/signal.c > @@ -2233,6 +2233,7 @@ static int ptrace_stop(int exit_code, int why, unsigned long message, > return exit_code; > > set_special_state(TASK_TRACED); > + smp_wmb(); > current->jobctl |= JOBCTL_TRACED; > Are not these both done under the sighand->siglock spinlock? That is, the two paths should already be synchronized, and the memory barriers will not help anything inside the locks. The locking should (and must) handle all that. -- Steve