Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4653149ioa; Wed, 27 Apr 2022 08:17:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEO5q3zonpHyor/uP9tsFMoms3iAtvrBAEAlzGDEcai8sYade7bjuhkJpWHVAjIidhoJH4 X-Received: by 2002:a17:902:f64c:b0:156:7ceb:b579 with SMTP id m12-20020a170902f64c00b001567cebb579mr28336173plg.73.1651072668545; Wed, 27 Apr 2022 08:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651072668; cv=none; d=google.com; s=arc-20160816; b=LFgbJp/Lat2q+4FCAiBku2mbWc0Lws81bT8Billk0HzrCh9nDPzNZwJZrCFhMAog8k /wIqxO60Vsa3N9C5YEAy3SifZDsSCqKMPQXOMoxPfxhcn3LRklEMAmOh81iGSyg1prhR m+q9NGqaj23BpwfI7hUK0Fo5E2r2cvg6iJroOcIq+li2VgUMGQrs2On3ocTb6bwG1ygq XTILErofP8RiRGCMSjRXzLikL8EQ3s2YRQSGbZD6Q9h4FnjEd6GJkiSVEmNgR2paLae0 05bry25KxbPuaPUJt+RaDDgotk17Ow5f2XfRp2DEDnB5tXCZXnpbeWiQ6nu5UKjAhGud BAcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:mime-version:user-agent:message-id :in-reply-to:date:references:cc:to:from; bh=pnIuhR0Rc2fZuKp/NeyJt+BSTRnookKOxGgN+AIt4k8=; b=SnrdOg4qq5nmNQvnBZ0m2x8QIPx6DllFJcSP1oAkUaf9oSg0oh5qZPKoTDxZOtmQby fAQ7P+lEY1tCIM3kR4899yKZ1XSdK8p8QfaFSGrAMlA9LkuV7x/HJk1dJz+dHnTlcBsd coBOWJ9FCPVpMcHtk/Ga4SFuW0EXk3thAP7AEaXv4pZCE4sv0Gn3lBdbXNvsKTzv9EQJ MKwmpmEgm3q8nWyWggncJ+3PTKqyRTMTUV2iz6OmprmMdhiqjftRuXzRYNejcrodr03r ym+dlbeg3dxh2rBz5G34CYp4xsA7pQ5ol91fCmXVwn1Sfp+QfljByaEWa3a4jcWQ8vsG OxXw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u81-20020a627954000000b0050d6ea9b033si1629652pfc.225.2022.04.27.08.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 08:17:48 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27F7D3DDCA; Wed, 27 Apr 2022 07:48:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238719AbiD0Ovq (ORCPT + 99 others); Wed, 27 Apr 2022 10:51:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238693AbiD0Oud (ORCPT ); Wed, 27 Apr 2022 10:50:33 -0400 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BFA43B297; Wed, 27 Apr 2022 07:47:21 -0700 (PDT) Received: from in02.mta.xmission.com ([166.70.13.52]:55074) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1njiwo-00H7U3-OG; Wed, 27 Apr 2022 08:47:18 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:35882 helo=email.froward.int.ebiederm.org.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1njiwn-00AnmM-Hj; Wed, 27 Apr 2022 08:47:18 -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> <874k2ea9q4.fsf@email.froward.int.ebiederm.org> Date: Wed, 27 Apr 2022 09:47:10 -0500 In-Reply-To: <874k2ea9q4.fsf@email.froward.int.ebiederm.org> (Eric W. Biederman's message of "Wed, 27 Apr 2022 09:20:51 -0500") Message-ID: <87zgk67fdd.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=1njiwn-00AnmM-Hj;;;mid=<87zgk67fdd.fsf@email.froward.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.174.4;;;frm=ebiederm@xmission.com;;;spf=softfail X-XM-AID: U2FsdGVkX1/9mpdQTyplIkPxPVrXFUt3r9iizls3AWY= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ******;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 575 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 11 (1.9%), b_tie_ro: 10 (1.7%), parse: 0.96 (0.2%), extract_message_metadata: 12 (2.1%), get_uri_detail_list: 1.46 (0.3%), tests_pri_-1000: 14 (2.4%), tests_pri_-950: 1.24 (0.2%), tests_pri_-900: 1.04 (0.2%), tests_pri_-90: 133 (23.2%), check_bayes: 132 (22.9%), b_tokenize: 8 (1.4%), b_tok_get_all: 9 (1.5%), b_comp_prob: 2.6 (0.5%), b_tok_touch_all: 108 (18.8%), b_finish: 1.03 (0.2%), tests_pri_0: 381 (66.4%), check_dkim_signature: 0.85 (0.1%), check_dkim_adsp: 3.4 (0.6%), poll_dns_idle: 0.87 (0.2%), tests_pri_10: 2.5 (0.4%), tests_pri_500: 15 (2.6%), rewrite_mail: 0.00 (0.0%) 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 in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Eric W. Biederman" writes: > 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. Hmm. If we have the following process tree. A \ B \ C Process A, B, and C are all in the same process group. Process A and B are setup to receive SIGCHILD when their process stops. Process C traces process A. When a sigstop is delivered to the group we can have: Process B takes siglock(B) siglock(A) to notify the real_parent Process C takes siglock(C) siglock(B) to notify the real_parent Process A takes siglock(A) siglock(C) to notify the tracer If they all take their local lock at the same time there is a deadlock. I don't think the restriction that you can never ptrace anyone up the process tree is going to fly. So it looks like I am back to the drawing board for this one. Eric