Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2436966iob; Sat, 30 Apr 2022 08:31:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWVTQJqkw4Fl0C7N/5TGa5UCFgLlqlaDVcm3zEwS14zwFdAwb7dMgydO1buiSZ67/pDnFG X-Received: by 2002:a17:902:f64c:b0:156:4349:7e9b with SMTP id m12-20020a170902f64c00b0015643497e9bmr4080886plg.139.1651332697355; Sat, 30 Apr 2022 08:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651332697; cv=none; d=google.com; s=arc-20160816; b=dpj7bgKmPflr1t5Qe4aYx4xc+m1cY0tjgqCiqTbLPwv8bjzjfmFE4OrFMd11uXwrYP 0I4uFT/e9fLOINnQ3sppO59+YsbUU6qvFTs9J1A/rZ2PfEpS4OYcwa6YCfJodHEj9pl8 iZMl/7gFA1um3VvAxWDPQBUOPWpU8taOd07ULmiJzxXCLVZdv6Q1FuFlAYZM+5nbC8Pt wPa3bbN8PHyOzlcoyrpD1/rECW4f2CpdIGB3WhWWZeWpUakaSDK1pj3m7Qxn5JkKgg4/ v8mB6phBJMC7J57apX0KJ52Hroo5zFrSsIYBh2Lx5z078DHsfGN2uRXztFa5c4zgaZGg IfGQ== 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=Qq72fPOyMsDMhllNPaD9/LDlbsltxPiZsmpBJxFx12M=; b=LIKKn4We3ShCaIbSzh774k3gLd9RlioNF8HwSrkV00cvM6xTH1yDFUrFdBaqa/yE6J M3+h5huPiCukk+eT1GQ17L18OnVX/yKBspHCYGEz/C6EnaO/zRejkoDxVQ06LkcDtAjb jGSgAVOW4a6Je5QGwJUpmetcQ4CY39559hFSihIH1kk4iGR9WKOhR/g/TkeTdV927SkY Jdn0YkY7uP7lPlvJ8Iw54GR3CnWWmIFykUcnUixUnUm+nSBEvhvPYPNNq0oltY+cHucs 6QAGxY0V5uTJFQIBAkLt46NIsJpPCnQ9bUjOQCrC7/odDqEK6oNvV1um2QtLqO1PUQ0C +Zfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=bgUEPOWf; 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 e17-20020a170903241100b0015e9605ae8bsi566572plo.123.2022.04.30.08.31.10; Sat, 30 Apr 2022 08:31:37 -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=desiato.20200630 header.b=bgUEPOWf; 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 S1352852AbiD1WXF (ORCPT + 99 others); Thu, 28 Apr 2022 18:23:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237230AbiD1WXC (ORCPT ); Thu, 28 Apr 2022 18:23:02 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47CFABF33A; Thu, 28 Apr 2022 15:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=Qq72fPOyMsDMhllNPaD9/LDlbsltxPiZsmpBJxFx12M=; b=bgUEPOWf/Yyr5FFK4XBq2PNbDK ZnBnUnZTZnH4A0oi3zwtEYUXvg1bFxVDJ9djmpADklpVYxA0JUDGJYQ93B9Dej5Y19KcHfdIvzxye vt70+dpRdjYt0Au0M5wjcYQtU4SV8zlHEftwLoxd8buL6j/tBqzAlabZeeYpXDVkxyDme6aMo481f PaCW3/T+NIK7wiJbl5wI6Hu1qrxRviFOfLwIKotaGj9nwklwVNvKIqFgE7B1uIVKvNivA9P3l9f6o 6nnvnAit53tlP6ZONb97iaa7gyJNlbnuQHONlrCwJ22CwYxC9TmeiufjLPDhuX0FYlos3+nl2oTJq PCd5j7Jg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nkCTl-009RWn-3g; Thu, 28 Apr 2022 22:19:17 +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) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E78EB30040C; Fri, 29 Apr 2022 00:19:14 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A998B202961EB; Fri, 29 Apr 2022 00:19:14 +0200 (CEST) Date: Fri, 29 Apr 2022 00:19:14 +0200 From: Peter Zijlstra To: "Eric W. Biederman" Cc: Oleg Nesterov , 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 6/9] signal: Always call do_notify_parent_cldstop with siglock held Message-ID: 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> <87zgk67fdd.fsf@email.froward.int.ebiederm.org> <8735hxxddw.fsf@email.froward.int.ebiederm.org> <87ilqtvsqg.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ilqtvsqg.fsf@email.froward.int.ebiederm.org> 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 Thu, Apr 28, 2022 at 03:49:11PM -0500, Eric W. Biederman wrote: > static void lock_parents_siglocks(bool lock_tracer) > __releases(¤t->sighand->siglock) > __acquires(¤t->sighand->siglock) > __acquires(¤t->real_parent->sighand->siglock) > __acquires(¤t->parent->sighand->siglock) > { > struct task_struct *me = current; > struct sighand_struct *m_sighand = me->sighand; > > lockdep_assert_held(&m_sighand->siglock); > > rcu_read_lock(); > for (;;) { > struct task_struct *parent, *tracer; > struct sighand_struct *p_sighand, *t_sighand, *s1, *s2, *s3; > > parent = me->real_parent; > tracer = lock_tracer? me->parent : parent; > > p_sighand = rcu_dereference(parent->sighand); > t_sighand = rcu_dereference(tracer->sighand); > > /* Sort the sighands so that s1 >= s2 >= s3 */ > s1 = m_sighand; > s2 = p_sighand; > s3 = t_sighand; > if (s1 > s2) > swap(s1, s2); > if (s1 > s3) > swap(s1, s3); > if (s2 > s3) > swap(s2, s3); > > if (s1 != m_sighand) { > spin_unlock(&m_sighand->siglock); > spin_lock(&s1->siglock); > } > > if (s1 != s2) > spin_lock_nested(&s2->siglock, SIGLOCK_LOCK_SECOND); > if (s2 != s3) > spin_lock_nested(&s3->siglock, SIGLOCK_LOCK_THIRD); > Might as well just use 1 and 2 for subclass at this point, or use SIGLOCK_LOCK_FIRST below. > if (likely((me->real_parent == parent) && > (me->parent == tracer) && > (parent->sighand == p_sighand) && > (tracer->sighand == t_sighand))) { > break; > } > spin_unlock(&p_sighand->siglock); > if (t_sighand != p_sighand) > spin_unlock(&t_sighand->siglock); Indent fail above ^, also you likey need this: /* * Since [pt]_sighand will likely change if we go * around, and m_sighand is the only one held, make sure * it is subclass-0, since the above 's1 != m_sighand' * clause very much relies on that. */ lock_set_subclass(&m_sighand->siglock, 0, _RET_IP_); > continue; > } > rcu_read_unlock(); > } > > Eric