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 D9A24C433EF for ; Wed, 6 Jul 2022 21:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231510AbiGFVXA (ORCPT ); Wed, 6 Jul 2022 17:23:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbiGFVW6 (ORCPT ); Wed, 6 Jul 2022 17:22:58 -0400 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB9D01A066 for ; Wed, 6 Jul 2022 14:22:57 -0700 (PDT) Received: from in01.mta.xmission.com ([166.70.13.51]:47138) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1o9CU2-000KRq-NH; Wed, 06 Jul 2022 15:22:54 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:35934 helo=email.froward.int.ebiederm.org.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1o9CU1-004OoQ-Pz; Wed, 06 Jul 2022 15:22:54 -0600 From: "Eric W. Biederman" To: Sven Schnelle Cc: Oleg Nesterov , Peter Zijlstra , Steven Rostedt , Alexander Gordeev , Kees Cook , linux-kernel@vger.kernel.org References: <20220706101625.2100298-1-svens@linux.ibm.com> Date: Wed, 06 Jul 2022 16:15:17 -0500 In-Reply-To: <20220706101625.2100298-1-svens@linux.ibm.com> (Sven Schnelle's message of "Wed, 6 Jul 2022 12:16:25 +0200") Message-ID: <87k08qlz8a.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1o9CU1-004OoQ-Pz;;;mid=<87k08qlz8a.fsf@email.froward.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.227.174.4;;;frm=ebiederm@xmission.com;;;spf=softfail X-XM-AID: U2FsdGVkX18r6LBKAPlBXmDEAPvZbvEiy1hnJuRFxrM= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH] ptrace: fix clearing of JOBCTL_TRACED in ptrace_unfreeze_traced() X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sven Schnelle writes: > CI reported the following splat while running the strace testsuite: > > [ 3976.640309] WARNING: CPU: 1 PID: 3570031 at kernel/ptrace.c:272 ptrace_check_attach+0x12e/0x178 > [ 3976.640391] CPU: 1 PID: 3570031 Comm: strace Tainted: G OE 5.19.0-20220624.rc3.git0.ee819a77d4e7.300.fc36.s390x #1 > [ 3976.640410] Hardware name: IBM 3906 M04 704 (z/VM 7.1.0) > [ 3976.640452] Call Trace: > [ 3976.640454] [<00000000ab4b645a>] ptrace_check_attach+0x132/0x178 > [ 3976.640457] ([<00000000ab4b6450>] ptrace_check_attach+0x128/0x178) > [ 3976.640460] [<00000000ab4b6cde>] __s390x_sys_ptrace+0x86/0x160 > [ 3976.640463] [<00000000ac03fcec>] __do_syscall+0x1d4/0x200 > [ 3976.640468] [<00000000ac04e312>] system_call+0x82/0xb0 > [ 3976.640470] Last Breaking-Event-Address: > [ 3976.640471] [<00000000ab4ea3c8>] wait_task_inactive+0x98/0x190 > > This is because JOBCTL_TRACED is set, but the task is not in TASK_TRACED > state. Caused by ptrace_unfreeze_traced() which does: > > task->jobctl &= ~TASK_TRACED > > but it should be: > > task->jobctl &= ~JOBCTL_TRACED That would definitely do it. I had to think about it for a few minutes to see how it explains some of the stranger behavior but it explains all of the funny behavior I have seen. Thank you for tracking this down. The fact the original bug report was on s390 had me somehow thinking this was s390 only. I will double check everything get this in linux-next and then send this to Linus. Eric > Fixes: 31cae1eaae4f ("sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state") > Signed-off-by: Sven Schnelle > --- > kernel/ptrace.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/ptrace.c b/kernel/ptrace.c > index 156a99283b11..1893d909e45c 100644 > --- a/kernel/ptrace.c > +++ b/kernel/ptrace.c > @@ -222,7 +222,7 @@ static void ptrace_unfreeze_traced(struct task_struct *task) > if (lock_task_sighand(task, &flags)) { > task->jobctl &= ~JOBCTL_PTRACE_FROZEN; > if (__fatal_signal_pending(task)) { > - task->jobctl &= ~TASK_TRACED; > + task->jobctl &= ~JOBCTL_TRACED; > wake_up_state(task, __TASK_TRACED); > } > unlock_task_sighand(task, &flags);