Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp882201iob; Thu, 28 Apr 2022 12:56:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4J4UbbMw+yIIDPCcOFpSa/8TQpF9tVcs2YhRG5EpkuVOIeJur5JhUCeKgsjqPccXJ+4OO X-Received: by 2002:ac2:484c:0:b0:472:357:f8fb with SMTP id 12-20020ac2484c000000b004720357f8fbmr17191600lfy.601.1651175793063; Thu, 28 Apr 2022 12:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651175793; cv=none; d=google.com; s=arc-20160816; b=l84OyaE2PZdZRV1xF/3o4tQLlg1b0vjpz1jvRLicpyC9nbzKlr9omZ7RgVwdsKRNWZ sdIocQ/sJP/j4ff/JfrIbSjeoNijBgBpBAlHySpwVX5o+sUE6piX49TfA5F1RMoFcJ6d D4gvIGmh9vO1nxqle+gjwPswvbRz8LH+aXJvyBzmN3lRrvKe4YWRE0KH0+nwTu+QvdtY vY9F3uA4m9p6RsbxdlKElxOee38uMtRSi6JJVBvPcL4CXAhVhnawxSkhEXxgc8bhjAJs beEwyQFPGarpp0sf3qzXf3XK7e+5vvaDNLloWb03tdzdWERmKbmk6OIJaC90XPX0PCnC OlHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3Obg7F2xg/HaVtg7kDbWxiOjI5aSvCmKfzGg6J1yzII=; b=HaUcD8avRnMU/AM8vP0W0r68DWjeISMk+LeTHZEriSMlJNeeJdJBKeWtqOVcEQaWjq KK2uZQEb0Ty+r0DuqyIa8Z1eqVF1MyZJiveUjv2+n9sKI+YS+StoaydsKKiJb0zbaACa mekYz5UlKoYFKMjKaH9o0aDMz94+7FjOTqlz2AXfgccneP107Z2poNRPMx3jPzF82KuA QUgjlvSAuHnK6rzZN2/1OnHx+XMi2Ph8RU5JrTn8VhlhYmXCZqaiJWhUe6v+Ua7hbgT1 1cuTbobqqgNfwQ8MCDiI2k9Umshc1ZIIe/LMwvb4vTZTH/fANK5uqMOAF45i9vPImyaQ S4lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EFM4kIJ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cf27-20020a056512281b00b00471a2f7c6b3si6165501lfb.66.2022.04.28.12.56.04; Thu, 28 Apr 2022 12:56:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EFM4kIJ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243801AbiD1Kpu (ORCPT + 99 others); Thu, 28 Apr 2022 06:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230119AbiD1Kpu (ORCPT ); Thu, 28 Apr 2022 06:45:50 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DBE58567B; Thu, 28 Apr 2022 03:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=3Obg7F2xg/HaVtg7kDbWxiOjI5aSvCmKfzGg6J1yzII=; b=EFM4kIJ6wFaaPwpVUPaRb/7dRu 9TqKQ2TZK3M4kIV+m+bpQm7t+HA3h3C8LF1+ipOYxmbkEoBeaQGZDfecqr0kzO2jCd0+ls6PRyUrF uSiN4dxQeTYOS2JEdN1Y23im0wDkcOf21YPOvRjHLf8Qgxl1WQEKY2POFK79narfg+v3YKRrsUOAZ 5tzb8hxc6G0F/4ugvMw3o/avE/RqQKuxWtpC9BFQAevt/cm8NHs70r4eqU1mU2rnLNei17c4n5IWR dOEaXIF7JcZw7qlInt661gVcJxWyvJ85l91scjKVP6IjMXwBB1cost3uXyBkpRJ8SzX/6/XBxsVb1 /EPxUamw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nk1b7-00BQWS-3l; Thu, 28 Apr 2022 10:42:09 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 875883001EA; Thu, 28 Apr 2022 12:42:07 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6F66A2029F872; Thu, 28 Apr 2022 12:42:07 +0200 (CEST) Date: Thu, 28 Apr 2022 12:42:07 +0200 From: Peter Zijlstra To: Oleg Nesterov Cc: "Eric W. Biederman" , linux-kernel@vger.kernel.org, rjw@rjwysocki.net, mingo@kernel.org, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, mgorman@suse.de, bigeasy@linutronix.de, Will Deacon , tj@kernel.org, linux-pm@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org, Chris Zankel , Max Filippov , inux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn Subject: Re: [PATCH 7/9] ptrace: Simplify the wait_task_inactive call in ptrace_check_attach Message-ID: References: <878rrrh32q.fsf_-_@email.froward.int.ebiederm.org> <20220426225211.308418-7-ebiederm@xmission.com> <20220427151455.GE17421@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220427151455.GE17421@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 27, 2022 at 05:14:57PM +0200, Oleg Nesterov wrote: > On 04/26, Eric W. Biederman wrote: > > > > Asking wait_task_inactive to verify that tsk->__state == __TASK_TRACED > > was needed to detect the when ptrace_stop would decide not to stop > > after calling "set_special_state(TASK_TRACED)". With the recent > > cleanups ptrace_stop will always stop after calling set_special_state. > > > > Take advatnage of this by no longer asking wait_task_inactive to > > verify the state. If a bug is hit and wait_task_inactive does not > > succeed warn and return -ESRCH. > > ACK, but I think that the changelog is wrong. > > We could do this right after may_ptrace_stop() has gone. This doesn't > depend on the previous changes in this series. It very much does rely on there not being any blocking between set_special_state() and schedule() tho. So all those PREEMPT_RT spinlock->rt_mutex things need to be gone. That is also the reason I couldn't do wait_task_inactive(task, 0) in the other patch, I had to really match 'TASK_TRACED or TASK_FROZEN' any other state must fail (specifically TASK_RTLOCK_WAIT must not match).