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 7549AC433F5 for ; Wed, 27 Apr 2022 14:21:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237619AbiD0OYS (ORCPT ); Wed, 27 Apr 2022 10:24:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237492AbiD0OYP (ORCPT ); Wed, 27 Apr 2022 10:24:15 -0400 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E603B236E02; Wed, 27 Apr 2022 07:21:02 -0700 (PDT) Received: from in01.mta.xmission.com ([166.70.13.51]:40666) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1njiXM-002Wzw-Se; Wed, 27 Apr 2022 08:21:00 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:35860 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 1njiXL-008Zam-HK; Wed, 27 Apr 2022 08:21:00 -0600 From: "Eric W. Biederman" To: Oleg Nesterov Cc: 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, Peter Zijlstra , Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org, Chris Zankel , Max Filippov , inux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn References: <878rrrh32q.fsf_-_@email.froward.int.ebiederm.org> <20220426225211.308418-6-ebiederm@xmission.com> <20220427141018.GA17421@redhat.com> Date: Wed, 27 Apr 2022 09:20:51 -0500 In-Reply-To: <20220427141018.GA17421@redhat.com> (Oleg Nesterov's message of "Wed, 27 Apr 2022 16:10:25 +0200") Message-ID: <874k2ea9q4.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=1njiXL-008Zam-HK;;;mid=<874k2ea9q4.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: U2FsdGVkX1+ttFsmGa6fQpHiGgFn4PTrxP8NleRq2Pw= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH 6/9] signal: Always call do_notify_parent_cldstop with siglock held 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-pm@vger.kernel.org Oleg Nesterov writes: > On 04/26, Eric W. Biederman wrote: >> >> @@ -2164,7 +2166,9 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, >> } >> >> sighand = parent->sighand; >> - spin_lock_irqsave(&sighand->siglock, flags); >> + lock = tsk->sighand != sighand; >> + if (lock) >> + spin_lock_nested(&sighand->siglock, SINGLE_DEPTH_NESTING); > > But why is it safe? > > Suppose we have two tasks, they both trace each other, both call > ptrace_stop() at the same time. Of course this is ugly, they both > will block. > > But with this patch in this case we have the trivial ABBA deadlock, > no? I was thinking in terms of the process tree (which is fine). The ptrace parental relationship definitely has the potential to be a graph with cycles. Which as you point out is not fine. The result is very nice and I don't want to give it up. I suspect something ptrace cycles are always a problem and can simply be forbidden. That is going to take some analsysis and some additional code in ptrace_attach. I will go look at that. Eric