From patchwork Wed May 18 22:53:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=WldVOBtv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3Sx36NmVz9vDx for ; Thu, 19 May 2022 08:54:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=luRDsfp4KM8ZL/jMTz/D6wAoxMVoQVZjn5kBBfYZdfw=; b=WldVOBtv5LLWCPnGooCvifeXR8 6eECQ446gHfiOXdgFCKasUIGCcKUi81YBDtVxwTMSHpu/bgz+n9Tvb1Xrispxq4CCGTWqn2VhlMJi 3A7ZgD4l4aySiKcJEmYYSk+mRNAe60bDxjp9xUgS8ldxIdmYKu0zqQWPmsJ7J1HeMxhJyzdjul5Ds Rz6v6MQBTfQBvhrW7xRyCgtIVVh8iBraDXXA7CcMYpfpTbgIfgvaq1rREjA1kSeDb6LNf4cdyHztl jwKs4u4HXH/14N9i3Ji+YLW0bHdyAWn9L8H+VJ9KtGM0jC+YK4t3/8BzbR4o1mVn/5nhQKLeKIvKA z/9jCqpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSYw-004BnS-43; Wed, 18 May 2022 22:54:38 +0000 Received: from out03.mta.xmission.com ([166.70.13.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSYt-004Bly-UM for linux-um@lists.infradead.org; Wed, 18 May 2022 22:54:37 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:60712) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSYj-00CkVI-6u; Wed, 18 May 2022 16:54:25 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSYf-002Z0O-Er; Wed, 18 May 2022 16:54:24 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" , linux-alpha@vger.kernel.org Date: Wed, 18 May 2022 17:53:40 -0500 Message-Id: <20220518225355.784371-1-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSYf-002Z0O-Er; ; ; mid=<20220518225355.784371-1-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX1+VdHu+AQ1uu8lMLBODEbaBhkaz/j3E23I= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: **** X-Spam-Status: No, score=4.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TM2_M_HEADER_IN_MSG, T_TooManySym_01,XMNoVowels,XMSubLong,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 2.5 XM_SPF_SoftFail SPF-SoftFail * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 3085 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 11 (0.4%), b_tie_ro: 9 (0.3%), parse: 1.24 (0.0%), extract_message_metadata: 19 (0.6%), get_uri_detail_list: 1.63 (0.1%), tests_pri_-1000: 22 (0.7%), tests_pri_-950: 1.20 (0.0%), tests_pri_-900: 1.05 (0.0%), tests_pri_-90: 83 (2.7%), check_bayes: 82 (2.7%), b_tokenize: 9 (0.3%), b_tok_get_all: 9 (0.3%), b_comp_prob: 2.2 (0.1%), b_tok_touch_all: 58 (1.9%), b_finish: 0.86 (0.0%), tests_pri_0: 211 (6.8%), check_dkim_signature: 0.49 (0.0%), check_dkim_adsp: 3.1 (0.1%), poll_dns_idle: 2720 (88.2%), tests_pri_10: 1.99 (0.1%), tests_pri_500: 2730 (88.5%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 01/16] signal/alpha: Remove unused definition of TASK_REAL_PARENT 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155436_046264_65B0C5B9 X-CRM114-Status: UNSURE ( 9.15 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Rather than update this defition when I move tsk->real_parent into signal_struct remove it now. Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: linux-alpha@vger.kernel.org Signed-off-by: "Eric W. Biederman" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Rather than update this defition when I move tsk->real_parent into signal_struct remove it now. Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: linux-alpha@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- arch/alpha/kernel/asm-offsets.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/alpha/kernel/asm-offsets.c b/arch/alpha/kernel/asm-offsets.c index 2e125e5c1508..0fca99dc5757 100644 --- a/arch/alpha/kernel/asm-offsets.c +++ b/arch/alpha/kernel/asm-offsets.c @@ -21,7 +21,6 @@ void foo(void) DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked)); DEFINE(TASK_CRED, offsetof(struct task_struct, cred)); - DEFINE(TASK_REAL_PARENT, offsetof(struct task_struct, real_parent)); DEFINE(TASK_GROUP_LEADER, offsetof(struct task_struct, group_leader)); DEFINE(TASK_TGID, offsetof(struct task_struct, tgid)); BLANK(); From patchwork Wed May 18 22:53:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=gv3GxeyF; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3Sx71fYzz9vDx for ; Thu, 19 May 2022 08:54:51 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=TOlurLXFkT/Rqoxs2/e+NwHJQNG0/oLvZdmXmERBdh8=; b=gv3GxeyFKD6895SRgnZK7fRi0w TMH+4pVTOq3eNAFJ3Ie8bR4o7JV4ir/y6Alc27vBX2j98zFsG0u1qvqllHnM6A0d/Dzq/5kJspLdP LOPKHP4G1q78+KzZLdW4I48ILzEHuMrYDeeiRKF8uit0NE1RgxRXYi393Iil/KB1ZLjherjYRwCQf fEgGrg/JufJKWqXDtBaCs7FnEwKkoIMELnNKVZ7vITTYiFJ51Fm289z+Ob5RuVM2wBvCjiaDUbk5g d/GuBlS3vSrESQD9xeQgshbdt6LlqqwoiiSxwLikJWo6BX460blB3Q8oYnFLcXut1HtZAdmp2aaSR Aclma16A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSYz-004BoE-DS; Wed, 18 May 2022 22:54:41 +0000 Received: from out03.mta.xmission.com ([166.70.13.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSYt-004Bm0-UM for linux-um@lists.infradead.org; Wed, 18 May 2022 22:54:38 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:60758) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSYm-00CkVS-Ou; Wed, 18 May 2022 16:54:28 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSYl-002Z0O-QC; Wed, 18 May 2022 16:54:28 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:41 -0500 Message-Id: <20220518225355.784371-2-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSYl-002Z0O-QC; ; ; mid=<20220518225355.784371-2-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX1+0Tx89ud0mnpvdpypNDCuPwLhWFRBvyWQ= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: ****** X-Spam-Status: No, score=6.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TM2_M_HEADER_IN_MSG, T_TooManySym_01,XMGappySubj_01,XMGappySubj_02,XMNoVowels,XMSubLong, XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 0.5 XMGappySubj_01 Very gappy subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 1.0 XMGappySubj_02 Gappier still * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 2.5 XM_SPF_SoftFail SPF-SoftFail * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ******;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 370 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 11 (2.9%), b_tie_ro: 9 (2.5%), parse: 0.93 (0.3%), extract_message_metadata: 11 (2.9%), get_uri_detail_list: 0.90 (0.2%), tests_pri_-1000: 15 (4.1%), tests_pri_-950: 1.19 (0.3%), tests_pri_-900: 1.03 (0.3%), tests_pri_-90: 107 (28.9%), check_bayes: 105 (28.4%), b_tokenize: 9 (2.3%), b_tok_get_all: 7 (2.0%), b_comp_prob: 2.0 (0.6%), b_tok_touch_all: 83 (22.5%), b_finish: 0.94 (0.3%), tests_pri_0: 210 (56.7%), check_dkim_signature: 0.50 (0.1%), check_dkim_adsp: 2.9 (0.8%), poll_dns_idle: 1.07 (0.3%), tests_pri_10: 2.2 (0.6%), tests_pri_500: 9 (2.4%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 02/16] signal/ia64: Remove unused definition of IA64_TASK_REAL_PARENT_OFFSET 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155436_046603_135C2DBA X-CRM114-Status: UNSURE ( 9.06 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Rather than update the unused definition of IA64_TASK_REAL_PARENT_OFFSENT when I move tsk->real_parent into signal_struct remove it now. Cc: linux-ia64@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- arch/ia64/kernel/asm-offsets.c | 1 - 1 file changed, 1 deletion(-) Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.233 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Rather than update the unused definition of IA64_TASK_REAL_PARENT_OFFSENT when I move tsk->real_parent into signal_struct remove it now. Cc: linux-ia64@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- arch/ia64/kernel/asm-offsets.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/ia64/kernel/asm-offsets.c b/arch/ia64/kernel/asm-offsets.c index be3b90fef2e9..245c4333ea30 100644 --- a/arch/ia64/kernel/asm-offsets.c +++ b/arch/ia64/kernel/asm-offsets.c @@ -55,7 +55,6 @@ void foo(void) DEFINE(IA64_PID_UPID_OFFSET, offsetof (struct pid, numbers[0])); DEFINE(IA64_TASK_PENDING_OFFSET,offsetof (struct task_struct, pending)); DEFINE(IA64_TASK_PID_OFFSET, offsetof (struct task_struct, pid)); - DEFINE(IA64_TASK_REAL_PARENT_OFFSET, offsetof (struct task_struct, real_parent)); DEFINE(IA64_TASK_SIGNAL_OFFSET,offsetof (struct task_struct, signal)); DEFINE(IA64_TASK_TGID_OFFSET, offsetof (struct task_struct, tgid)); DEFINE(IA64_TASK_THREAD_KSP_OFFSET, offsetof (struct task_struct, thread.ksp)); From patchwork Wed May 18 22:53:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632989 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=kN6PnfWK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3Sx83J9Pz9vDx for ; Thu, 19 May 2022 08:54:52 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rg5tDbHR/tnS7kByQw68wARJRngUW+TZBhapDo3BsJ4=; b=kN6PnfWKH3spVtDNTCKzavPpVi 8TnjrtN5Oy14a3SbVzny7OMtwwbJeuk84K1g6foNLF91JykWmLXd0fdTB19QN2cvxLmzKGiXG4CaL hQwH9/PfKZF63QLpI71nIwpToGtEEouLEvOZm5wLbyVI4HXrEOE2L0/nq2HVzrYqqOuGkon7Vq+eZ 8Zte7YugUje2AOx/Uo2UvE9BlIpFf+To98cAlDGz5bWhm6IHhe4gIzgXFK04OVrHw6hXURGmp51jd vxdwoMczknBVH8EWDu5D+8u8QGbGVB/2WiJuFGhOhe+TSRAttCcfZHZkeWBUyXVnc1BggISPJIrDL 8iP3x9gQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSYz-004BoU-Lk; Wed, 18 May 2022 22:54:41 +0000 Received: from out01.mta.xmission.com ([166.70.13.231]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSYv-004Blt-SG for linux-um@lists.infradead.org; Wed, 18 May 2022 22:54:39 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:54682) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSYr-001T3j-Ut; Wed, 18 May 2022 16:54:33 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSYp-002Z0O-Ef; Wed, 18 May 2022 16:54:33 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:42 -0500 Message-Id: <20220518225355.784371-3-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSYp-002Z0O-Ef; ; ; mid=<20220518225355.784371-3-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX1+Nwc5NJ6zP1i47DbDDS+c6gRtGHkZGyR8= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa06.xmission.com X-Spam-Level: **** X-Spam-Status: No, score=4.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TM2_M_HEADER_IN_MSG, T_TooManySym_01,XMNoVowels,XMSubLong,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 0.0 T_TooManySym_01 4+ unique symbols in subject * 2.5 XM_SPF_SoftFail SPF-SoftFail X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 1894 ms - load_scoreonly_sql: 0.07 (0.0%), signal_user_changed: 12 (0.6%), b_tie_ro: 10 (0.6%), parse: 1.17 (0.1%), extract_message_metadata: 24 (1.3%), get_uri_detail_list: 1.39 (0.1%), tests_pri_-1000: 45 (2.4%), tests_pri_-950: 1.38 (0.1%), tests_pri_-900: 1.14 (0.1%), tests_pri_-90: 98 (5.2%), check_bayes: 96 (5.1%), b_tokenize: 10 (0.5%), b_tok_get_all: 8 (0.4%), b_comp_prob: 3.0 (0.2%), b_tok_touch_all: 71 (3.8%), b_finish: 1.01 (0.1%), tests_pri_0: 295 (15.6%), check_dkim_signature: 0.61 (0.0%), check_dkim_adsp: 6 (0.3%), poll_dns_idle: 1393 (73.6%), tests_pri_10: 2.2 (0.1%), tests_pri_500: 1410 (74.4%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 03/16] kdb: Use real_parent when displaying a list of processes 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155437_949002_51184D65 X-CRM114-Status: GOOD ( 12.74 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: kdb has a bug that when using the ps command to display a list of processes, if a process is being debugged the debugger as the parent process. This is silly, and I expect it never comes up in ptractice. As there is very little point in using gdb and kdb simultaneously. Update the code to use real_parent so that it is clear kdb does not want [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.231 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [166.70.13.231 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org kdb has a bug that when using the ps command to display a list of processes, if a process is being debugged the debugger as the parent process. This is silly, and I expect it never comes up in ptractice. As there is very little point in using gdb and kdb simultaneously. Update the code to use real_parent so that it is clear kdb does not want to display a debugger as the parent of a process. Cc: Jason Wessel Cc: Daniel Thompson Cc: Douglas Anderson Fixes: 5d5314d6795f ("kdb: core for kgdb back end (1 of 2)" Signed-off-by: "Eric W. Biederman" --- kernel/debug/kdb/kdb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 0852a537dad4..db49f1026eaa 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -2306,7 +2306,7 @@ void kdb_ps1(const struct task_struct *p) cpu = kdb_process_cpu(p); kdb_printf("0x%px %8d %8d %d %4d %c 0x%px %c%s\n", - (void *)p, p->pid, p->parent->pid, + (void *)p, p->pid, p->real_parent->pid, kdb_task_has_cpu(p), kdb_process_cpu(p), kdb_task_state_char(p), (void *)(&p->thread), From patchwork Wed May 18 22:53:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632990 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=AIY7b0mZ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3SxC4sZqz9vDx for ; Thu, 19 May 2022 08:54:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ZS9Nih4l1LzVaOdpfKR9N6AcgRUJto416LVLkXBL82c=; b=AIY7b0mZyCmvvAf3UipaaVY3ml aYs/R178ab0e3xa4IvAcGoQ2jo0hHk5dbymCqCugjqmMA6i+OzLF7YhY6x0tJbCzrSEejM9YOHjs1 qv8erEHgXZRc2qs24wMNeWmGt5J17vJsJlL/gnkbKVyPtB4DnG7POIQP8TAi+D27+Hi2qLtvpNUpY /X5RHH7Nz2akZob/TSdyLd0vg6PgU1bHWQdowA3/F9UPWddmOh/E3Hsb9bCo0pV/DlnyDYC3grI2C J93UcERwh/U3vSjfq8tLbFqmLaLYIeqVAU0xcPYX6OZCl817C10yZptEboJ0/31wyynD1sFnBndSR 3bCtnvcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZ4-004Brn-TK; Wed, 18 May 2022 22:54:46 +0000 Received: from out02.mta.xmission.com ([166.70.13.232]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZ2-004Bpk-4a for linux-um@lists.infradead.org; Wed, 18 May 2022 22:54:45 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:54926) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSYx-003baE-OK; Wed, 18 May 2022 16:54:39 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSYu-002Z0O-LI; Wed, 18 May 2022 16:54:38 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:43 -0500 Message-Id: <20220518225355.784371-4-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSYu-002Z0O-LI; ; ; mid=<20220518225355.784371-4-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX1/XPnwfZQEHyZ9WrXatAJldgaE0eiN7zxc= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa06.xmission.com X-Spam-Level: **** X-Spam-Status: No, score=4.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TM2_M_HEADER_IN_MSG, T_TooManySym_01,XMNoVowels,XMSubLong,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 0.0 T_TooManySym_01 4+ unique symbols in subject * 2.5 XM_SPF_SoftFail SPF-SoftFail X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 2130 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 12 (0.5%), b_tie_ro: 10 (0.5%), parse: 1.13 (0.1%), extract_message_metadata: 26 (1.2%), get_uri_detail_list: 1.81 (0.1%), tests_pri_-1000: 21 (1.0%), tests_pri_-950: 1.26 (0.1%), tests_pri_-900: 1.05 (0.0%), tests_pri_-90: 235 (11.0%), check_bayes: 204 (9.6%), b_tokenize: 22 (1.0%), b_tok_get_all: 12 (0.5%), b_comp_prob: 7 (0.3%), b_tok_touch_all: 157 (7.4%), b_finish: 3.3 (0.2%), tests_pri_0: 300 (14.1%), check_dkim_signature: 1.16 (0.1%), check_dkim_adsp: 8 (0.4%), poll_dns_idle: 1487 (69.8%), tests_pri_10: 3.5 (0.2%), tests_pri_500: 1526 (71.6%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 04/16] powerpc/xmon: Use real_parent when displaying a list of processes 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155444_257246_54F2593B X-CRM114-Status: GOOD ( 13.10 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: xmon has a bug (copied from kdb) that when showing a list of processes the debugger is listed as the parent, if a processes is being debugged. This is silly, and I expect it is rare enough no has noticed in practice. Update the code to use real_parent so that it is clear xmon does not want to display a debugger as the parent of a process. Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.232 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [166.70.13.232 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org xmon has a bug (copied from kdb) that when showing a list of processes the debugger is listed as the parent, if a processes is being debugged. This is silly, and I expect it is rare enough no has noticed in practice. Update the code to use real_parent so that it is clear xmon does not want to display a debugger as the parent of a process. Cc: Douglas Miller Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Fixes: 6dfb54049f9a ("powerpc/xmon: Add xmon command to dump process/task similar to ps(1)") Signed-off-by: "Eric W. Biederman" --- arch/powerpc/xmon/xmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index fd72753e8ad5..b308ef9ce604 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -3282,7 +3282,7 @@ static void show_task(struct task_struct *volatile tsk) printf("%16px %16lx %16px %6d %6d %c %2d %s\n", tsk, tsk->thread.ksp, tsk->thread.regs, - tsk->pid, rcu_dereference(tsk->parent)->pid, + tsk->pid, rcu_dereference(tsk->real_parent)->pid, state, task_cpu(tsk), tsk->comm); } From patchwork Wed May 18 22:53:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632991 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=TO8dl6C/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3SxD6QpZz9vDx for ; Thu, 19 May 2022 08:54:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ylZ6XM1dzbSYz4QlGZo7LtCnrPtLUC2hYFdj1sWO4K4=; b=TO8dl6C/PMI+Yl6ff9jhoTsmIb /T96gvU/JT1qTh4C7UaL4MzDDDOBAItaBYQVF6shYRxPyqvseVTiY0zPPRHi3yDowL+i9ARxDv11f LySLkXD0OqKSMMP+c690lHYU8+DkwpnL8cvf1WNvtY+7MPbB/0VS8KPsmZwJWp1L0G2G6Rt5Mq1A5 6LrO8TIB+WPLlS3qcKHIPe4rMKOKGGt1wPff0oLyL9ZQNsfEiS0n5ZtoThEy3ab0Qj+Mpo82qPILG +na/9qDqVobPaG4oy5b6QHJgBf+zReLkBFJwMMMksR6kbdeIOugVVpdNy0uxGj2OO1uYtOo9Z/5Gk L4m5r2Cw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZ6-004Bso-44; Wed, 18 May 2022 22:54:48 +0000 Received: from out01.mta.xmission.com ([166.70.13.231]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZ2-004BqF-LW for linux-um@lists.infradead.org; Wed, 18 May 2022 22:54:46 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:54828) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZ1-001T58-Fx; Wed, 18 May 2022 16:54:43 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZ0-002Z0O-DQ; Wed, 18 May 2022 16:54:43 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:44 -0500 Message-Id: <20220518225355.784371-5-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZ0-002Z0O-DQ; ; ; mid=<20220518225355.784371-5-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX19bmUj59Un5KGL2qB5b8KKLljIsiq43aWI= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa06.xmission.com X-Spam-Level: *** X-Spam-Status: No, score=3.8 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TooManySym_01,XMNoVowels, XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 0.0 T_TooManySym_01 4+ unique symbols in subject * 2.5 XM_SPF_SoftFail SPF-SoftFail X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ***;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 409 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 11 (2.6%), b_tie_ro: 9 (2.3%), parse: 0.95 (0.2%), extract_message_metadata: 14 (3.4%), get_uri_detail_list: 1.15 (0.3%), tests_pri_-1000: 18 (4.3%), tests_pri_-950: 1.26 (0.3%), tests_pri_-900: 1.31 (0.3%), tests_pri_-90: 69 (16.7%), check_bayes: 66 (16.2%), b_tokenize: 11 (2.6%), b_tok_get_all: 8 (2.1%), b_comp_prob: 2.7 (0.6%), b_tok_touch_all: 41 (10.1%), b_finish: 1.05 (0.3%), tests_pri_0: 282 (68.8%), check_dkim_signature: 0.54 (0.1%), check_dkim_adsp: 3.6 (0.9%), poll_dns_idle: 0.99 (0.2%), tests_pri_10: 2.1 (0.5%), tests_pri_500: 8 (1.9%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 05/16] ptrace: Remove dead code from __ptrace_detach 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155444_781557_F9AF0AFD X-CRM114-Status: GOOD ( 14.69 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Ever since commit 28d838cc4dfe ("Fix ptrace self-attach rule") it has been impossible to attach another thread in the same thread group. Remove the code from __ptrace_detach that was trying to support detaching from a thread in the same thread group. The code is dead and I can not make sense of what it is trying to do. Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [166.70.13.231 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.231 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Ever since commit 28d838cc4dfe ("Fix ptrace self-attach rule") it has been impossible to attach another thread in the same thread group. Remove the code from __ptrace_detach that was trying to support detaching from a thread in the same thread group. The code is dead and I can not make sense of what it is trying to do. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 328a34a99124..ca0e47691229 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -526,19 +526,6 @@ static int ptrace_traceme(void) return ret; } -/* - * Called with irqs disabled, returns true if childs should reap themselves. - */ -static int ignoring_children(struct sighand_struct *sigh) -{ - int ret; - spin_lock(&sigh->siglock); - ret = (sigh->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) || - (sigh->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT); - spin_unlock(&sigh->siglock); - return ret; -} - /* * Called with tasklist_lock held for writing. * Unlink a traced task, and clean it up if it was a traced zombie. @@ -565,14 +552,9 @@ static bool __ptrace_detach(struct task_struct *tracer, struct task_struct *p) dead = !thread_group_leader(p); - if (!dead && thread_group_empty(p)) { - if (!same_thread_group(p->real_parent, tracer)) - dead = do_notify_parent(p, p->exit_signal); - else if (ignoring_children(tracer->sighand)) { - __wake_up_parent(p, tracer); - dead = true; - } - } + if (!dead && thread_group_empty(p)) + dead = do_notify_parent(p, p->exit_signal); + /* Mark it as in the process of being reaped. */ if (dead) p->exit_state = EXIT_DEAD; From patchwork Wed May 18 22:53:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=J9asuyXV; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3SxH42byz9vDx for ; Thu, 19 May 2022 08:54:59 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=eLGej0RwsQwVSc88HGAq9jJlgYm398tUdq88rQ3nG84=; b=J9asuyXVnLSjg7VDUqgQA89t1j KaWnFVxTvucQvekF4h1NYjQsJD3hjO7xWRGbMJcfXWrot8Mszra52zrRLhM0nqMv/ubm34MrFi9Zd 8Hby+ifuMK5VA4wfJGG0GSCPtzmYRw9ojEDhspPRF+kn5u8xWuHIif84w6bok+n8BZkPRCHSDCPzg bpUYHX+Wa1UdLuGRidM7mTklvKcwan0tQ9GxVgLd/DmwfuCIcswb14S7qlYWGVIs7Jby0ZyYs6vjm 2OBzFSTsR75pl1AeRLC68WoQkFl02MC8Mr5T2FXxxBDLnyO0KBxxlsDjqqghHtpFzt/ewQCUEhVOz sqj2g9xQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZ9-004Bv1-DD; Wed, 18 May 2022 22:54:51 +0000 Received: from out03.mta.xmission.com ([166.70.13.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZ6-004Bta-OF for linux-um@lists.infradead.org; Wed, 18 May 2022 22:54:50 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:32820) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZ5-00CkXx-Ei; Wed, 18 May 2022 16:54:47 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZ4-002Z0O-4S; Wed, 18 May 2022 16:54:46 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:45 -0500 Message-Id: <20220518225355.784371-6-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZ4-002Z0O-4S; ; ; mid=<20220518225355.784371-6-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX18JPO9y9/8egXH47VwwlNDJMZCh2Vmg12Y= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa05.xmission.com X-Spam-Level: ****** X-Spam-Status: No, score=6.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TR_Symld_Words,T_TooManySym_01,T_TooManySym_02, T_TooManySym_03,T_TooManySym_04,XMNoVowels,XMSubLong,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 1.5 TR_Symld_Words too many words that have symbols inside * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa05 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_04 7+ unique symbols in subject * 0.0 T_TooManySym_03 6+ unique symbols in subject * 0.0 T_TooManySym_01 4+ unique symbols in subject * 2.5 XM_SPF_SoftFail SPF-SoftFail * 0.0 T_TooManySym_02 5+ unique symbols in subject X-Spam-DCC: XMission; sa05 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ******;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 374 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 10 (2.7%), b_tie_ro: 9 (2.4%), parse: 0.83 (0.2%), extract_message_metadata: 9 (2.4%), get_uri_detail_list: 0.97 (0.3%), tests_pri_-1000: 13 (3.4%), tests_pri_-950: 1.02 (0.3%), tests_pri_-900: 0.95 (0.3%), tests_pri_-90: 60 (15.9%), check_bayes: 58 (15.6%), b_tokenize: 8 (2.2%), b_tok_get_all: 8 (2.2%), b_comp_prob: 1.93 (0.5%), b_tok_touch_all: 37 (9.8%), b_finish: 0.81 (0.2%), tests_pri_0: 268 (71.6%), check_dkim_signature: 0.47 (0.1%), check_dkim_adsp: 2.2 (0.6%), poll_dns_idle: 0.74 (0.2%), tests_pri_10: 1.84 (0.5%), tests_pri_500: 8 (2.1%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 06/16] ptrace: Remove unnecessary locking in ptrace_(get|set)siginfo 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155448_832182_EB608DD0 X-CRM114-Status: GOOD ( 12.06 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Since commit 9899d11f6544 ("ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL") it has been unnecessary for ptrace_getsiginfo and ptrace_setsiginfo to use lock_task_sighand. Having the code taking an unnecessary lock is confusing as it suggests that other parts of the code need to take the unnecessary lock as well. Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.233 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Since commit 9899d11f6544 ("ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL") it has been unnecessary for ptrace_getsiginfo and ptrace_setsiginfo to use lock_task_sighand. Having the code taking an unnecessary lock is confusing as it suggests that other parts of the code need to take the unnecessary lock as well. So remove the unnecessary lock to make the code more efficient, simpler, and less confusing. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index ca0e47691229..15e93eafa6f0 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -677,34 +677,20 @@ static int ptrace_setoptions(struct task_struct *child, unsigned long data) static int ptrace_getsiginfo(struct task_struct *child, kernel_siginfo_t *info) { - unsigned long flags; - int error = -ESRCH; + if (unlikely(!child->last_siginfo)) + return -EINVAL; - if (lock_task_sighand(child, &flags)) { - error = -EINVAL; - if (likely(child->last_siginfo != NULL)) { - copy_siginfo(info, child->last_siginfo); - error = 0; - } - unlock_task_sighand(child, &flags); - } - return error; + copy_siginfo(info, child->last_siginfo); + return 0; } static int ptrace_setsiginfo(struct task_struct *child, const kernel_siginfo_t *info) { - unsigned long flags; - int error = -ESRCH; + if (unlikely(!child->last_siginfo)) + return -EINVAL; - if (lock_task_sighand(child, &flags)) { - error = -EINVAL; - if (likely(child->last_siginfo != NULL)) { - copy_siginfo(child->last_siginfo, info); - error = 0; - } - unlock_task_sighand(child, &flags); - } - return error; + copy_siginfo(child->last_siginfo, info); + return 0; } static int ptrace_peek_siginfo(struct task_struct *child, From patchwork Wed May 18 22:53:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632993 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ydRubwJZ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3SxP46hyz9vDx for ; Thu, 19 May 2022 08:55:05 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=MxUdCBoWTg+vIfJqgYwTI99tRY+/wLoYm3Pq3Qd3U3c=; b=ydRubwJZJswuQcVNOpZGltuCqZ d/g1DZ4ZRkDhzig3JHceaPBLIJxVp2M8qM3MQ41G6gCSe1HWBr3HJFg/XcrtSm6pzRVEyxmwkM4k3 i+EIu56ACNsuur6ytO0zXUq9il/5RdCOsl+E/dn7SvdnLK7rLLu0eClGChfM73beweduSiznYdjnI s0yZcNF6lIgOrc1PusoADmJ3OwLl+L561E7RCcF6YLxvF0doKFT2LdDQJdtfSdSVz5aAIvQfntO/g edKinfM3SLaLgbPtZh/QYy52do0lVAqHmj9ywTN9g+7cppqbIghPUadf0TtBe//1PKVojodNtwx6u ZYOTG/LQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZD-004Byb-RG; Wed, 18 May 2022 22:54:55 +0000 Received: from out01.mta.xmission.com ([166.70.13.231]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZ9-004Bvj-V5 for linux-um@lists.infradead.org; Wed, 18 May 2022 22:54:53 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:54962) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZ9-001T6U-1F; Wed, 18 May 2022 16:54:51 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZ8-002Z0O-20; Wed, 18 May 2022 16:54:50 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:46 -0500 Message-Id: <20220518225355.784371-7-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZ8-002Z0O-20; ; ; mid=<20220518225355.784371-7-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX19piXvSGZGlwtEypRa3+k4c3ag8pD6xkSw= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: *** X-Spam-Status: No, score=3.8 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TM2_M_HEADER_IN_MSG, XMNoVowels,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 2.5 XM_SPF_SoftFail SPF-SoftFail * -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ***;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 369 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 11 (3.0%), b_tie_ro: 10 (2.6%), parse: 0.97 (0.3%), extract_message_metadata: 11 (3.1%), get_uri_detail_list: 1.11 (0.3%), tests_pri_-1000: 16 (4.2%), tests_pri_-950: 1.20 (0.3%), tests_pri_-900: 1.04 (0.3%), tests_pri_-90: 66 (17.8%), check_bayes: 64 (17.4%), b_tokenize: 10 (2.6%), b_tok_get_all: 8 (2.2%), b_comp_prob: 2.3 (0.6%), b_tok_touch_all: 41 (11.1%), b_finish: 0.81 (0.2%), tests_pri_0: 249 (67.4%), check_dkim_signature: 0.54 (0.1%), check_dkim_adsp: 2.6 (0.7%), poll_dns_idle: 0.83 (0.2%), tests_pri_10: 2.2 (0.6%), tests_pri_500: 9 (2.3%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 07/16] signal: Wake up the designated parent 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155452_043102_F1490AAE X-CRM114-Status: GOOD ( 12.75 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Today if a process is ptraced only the ptracer will ever be woken up in wait, if the parent is waiting with __WNOTHREAD. Update the code so that the real_parent can also be woken up with __WNOTHREAD e [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [166.70.13.231 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.231 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Today if a process is ptraced only the ptracer will ever be woken up in wait, if the parent is waiting with __WNOTHREAD. Update the code so that the real_parent can also be woken up with __WNOTHREAD even when the code is ptraced. Fixes: 75b95953a569 ("job control: Add @for_ptrace to do_notify_parent_cldstop()") Signed-off-by: "Eric W. Biederman" --- kernel/exit.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index f072959fcab7..0e26f73c49ac 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1421,26 +1421,35 @@ static int ptrace_do_wait(struct wait_opts *wo, struct task_struct *tsk) return 0; } +struct child_wait_info { + struct task_struct *p; + struct task_struct *parent; +}; + static int child_wait_callback(wait_queue_entry_t *wait, unsigned mode, int sync, void *key) { struct wait_opts *wo = container_of(wait, struct wait_opts, child_wait); - struct task_struct *p = key; + struct child_wait_info *info = key; - if (!eligible_pid(wo, p)) + if (!eligible_pid(wo, info->p)) return 0; - if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent) - return 0; + if ((wo->wo_flags & __WNOTHREAD) && (wait->private != info->parent)) + return 0; return default_wake_function(wait, mode, sync, key); } void __wake_up_parent(struct task_struct *p, struct task_struct *parent) { + struct child_wait_info info = { + .p = p, + .parent = parent, + }; __wake_up_sync_key(&parent->signal->wait_chldexit, - TASK_INTERRUPTIBLE, p); + TASK_INTERRUPTIBLE, &info); } static bool is_effectively_child(struct wait_opts *wo, bool ptrace, From patchwork Wed May 18 22:53:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632994 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Tf7arFte; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3SxS19JGz9vDx for ; Thu, 19 May 2022 08:55:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=oYgcxRdW1dDUGAqEff5fqnaWqfuBBiWKhSTkRZaH1x8=; b=Tf7arFte7usxSSToej/+pjcX9p zMO6ZKJmv3Z6Tb9gsWnZUUx49jbbOpO72tEDW1Gy4oChQWXwu2MdVojXSGUvalS9bWvWUXaWrhrAc kdGNVRt2KN/coB4IDJFRKm0/+4jsuYV95S8HCvVobAEw5u+K1APpvapaAcN4LplHuQf6gubWYsKxr +eVbb2Zz5yUHQXejr+t+zvVq6J017bSaHXDzfgjK0YD0XKy+9t0M4MUFI6JOePhctc4Ew9uiN+/wB PAnvfmPYsrh7w7MysqvHC4IGIo3MOJPcEqNMpsGFjcDuHg4q4EWiaas8K/BCENKAnywwvoe8akp+R yr588TYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZH-004C1Z-VG; Wed, 18 May 2022 22:54:59 +0000 Received: from out02.mta.xmission.com ([166.70.13.232]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZD-004ByY-RX for linux-um@lists.infradead.org; Wed, 18 May 2022 22:54:57 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:55168) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZC-003bc3-Uc; Wed, 18 May 2022 16:54:54 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZB-002Z0O-N6; Wed, 18 May 2022 16:54:54 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:47 -0500 Message-Id: <20220518225355.784371-8-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZB-002Z0O-N6; ; ; mid=<20220518225355.784371-8-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX19U9H+LaT04oPfJY3DaaeOb2O0QxRcclq0= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa06.xmission.com X-Spam-Level: ***** X-Spam-Status: No, score=5.7 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TM2_M_HEADER_IN_MSG, T_TooManySym_01,XMNoVowels,XMSubLong,XM_B_SpammyWords, XM_Body_Dirty_Words,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 1.0 XM_Body_Dirty_Words Contains a dirty word * 0.0 T_TooManySym_01 4+ unique symbols in subject * 2.5 XM_SPF_SoftFail SPF-SoftFail * 0.2 XM_B_SpammyWords One or more commonly used spammy words X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *****;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 586 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 8 (1.4%), b_tie_ro: 7 (1.2%), parse: 1.03 (0.2%), extract_message_metadata: 12 (2.0%), get_uri_detail_list: 2.2 (0.4%), tests_pri_-1000: 15 (2.6%), tests_pri_-950: 1.33 (0.2%), tests_pri_-900: 1.04 (0.2%), tests_pri_-90: 166 (28.3%), check_bayes: 164 (28.0%), b_tokenize: 12 (2.1%), b_tok_get_all: 11 (1.8%), b_comp_prob: 2.8 (0.5%), b_tok_touch_all: 135 (23.0%), b_finish: 0.90 (0.2%), tests_pri_0: 370 (63.1%), check_dkim_signature: 0.62 (0.1%), check_dkim_adsp: 2.9 (0.5%), poll_dns_idle: 1.12 (0.2%), tests_pri_10: 2.1 (0.4%), tests_pri_500: 7 (1.2%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 08/16] ptrace: Only populate last_siginfo from ptrace 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155455_970266_E4EA7689 X-CRM114-Status: GOOD ( 17.97 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The code in ptrace_signal to populate siginfo if the signal number changed is buggy. If the tracer contined the tracee using ptrace_detach it is guaranteed to use the real_parent (or possibly a new tr [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [166.70.13.232 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.232 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The code in ptrace_signal to populate siginfo if the signal number changed is buggy. If the tracer contined the tracee using ptrace_detach it is guaranteed to use the real_parent (or possibly a new tracer) but definitely not the origional tracer to populate si_pid and si_uid. Fix this bug by only updating siginfo from the tracer so that the tracers pid and the tracers uid are always used. If it happens that ptrace_resume or ptrace_detach don't have a signal to continue with clear siginfo. This is a very old bug that has been fixable since commit 1669ce53e2ff ("Add PTRACE_GETSIGINFO and PTRACE_SETSIGINFO") when last_siginfo was introduced and the tracer could change siginfo. Fixes: v2.1.68 History-Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 31 +++++++++++++++++++++++++++++-- kernel/signal.c | 18 ------------------ 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 15e93eafa6f0..a24eed725cec 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -526,6 +526,33 @@ static int ptrace_traceme(void) return ret; } +static void ptrace_set_signr(struct task_struct *child, unsigned int signr) +{ + struct kernel_siginfo *info = child->last_siginfo; + + child->exit_code = signr; + /* + * Update the siginfo structure if the signal has + * changed. If the debugger wanted something + * specific in the siginfo structure then it should + * have updated *info via PTRACE_SETSIGINFO. + */ + if (info && (info->si_signo != signr)) { + clear_siginfo(info); + + if (signr != 0) { + info->si_signo = signr; + info->si_errno = 0; + info->si_code = SI_USER; + rcu_read_lock(); + info->si_pid = task_pid_nr_ns(current, task_active_pid_ns(child)); + info->si_uid = from_kuid_munged(task_cred_xxx(child, user_ns), + current_uid()); + rcu_read_unlock(); + } + } +} + /* * Called with tasklist_lock held for writing. * Unlink a traced task, and clean it up if it was a traced zombie. @@ -579,7 +606,7 @@ static int ptrace_detach(struct task_struct *child, unsigned int data) * tasklist_lock avoids the race with wait_task_stopped(), see * the comment in ptrace_resume(). */ - child->exit_code = data; + ptrace_set_signr(child, data); __ptrace_detach(current, child); write_unlock_irq(&tasklist_lock); @@ -851,7 +878,7 @@ static int ptrace_resume(struct task_struct *child, long request, * wait_task_stopped() after resume. */ spin_lock_irq(&child->sighand->siglock); - child->exit_code = data; + ptrace_set_signr(child, data); child->jobctl &= ~JOBCTL_TRACED; wake_up_state(child, __TASK_TRACED); spin_unlock_irq(&child->sighand->siglock); diff --git a/kernel/signal.c b/kernel/signal.c index e782c2611b64..ff4a52352390 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2562,24 +2562,6 @@ static int ptrace_signal(int signr, kernel_siginfo_t *info, enum pid_type type) if (signr == 0) return signr; - /* - * Update the siginfo structure if the signal has - * changed. If the debugger wanted something - * specific in the siginfo structure then it should - * have updated *info via PTRACE_SETSIGINFO. - */ - if (signr != info->si_signo) { - clear_siginfo(info); - info->si_signo = signr; - info->si_errno = 0; - info->si_code = SI_USER; - rcu_read_lock(); - info->si_pid = task_pid_vnr(current->parent); - info->si_uid = from_kuid_munged(current_user_ns(), - task_uid(current->parent)); - rcu_read_unlock(); - } - /* If the (new) signal is now blocked, requeue it. */ if (sigismember(¤t->blocked, signr) || fatal_signal_pending(current)) { From patchwork Wed May 18 22:53:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632995 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=s3WnDPec; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3SxV1VZBz9vDx for ; Thu, 19 May 2022 08:55:10 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=9R+csaP08qQ4W9w/4Sj8F2yDwtgQiQhbmppF0S/dWCU=; b=s3WnDPecgn2ioFIVz7S0lF4Ahb lNa6mSkK1YLS1rp2MzqmnGqGzTpbuJ6oDbAReCJMQOLOhMH/Taxcmui7DJE/fg4xe7awIJoYZULg5 +w39ooYuFnX07RNfIKpRYzznhCdRe7GmOTvWQPrZ7alfEHDnJhUVuCgoZZsVkJyK504XNiWZ+UGeM haQeYIxo/7nu9K+pcynEIsT9mbhoX0cRxiqw7txotxMgunoKxJzvZG3mjE6bCgpE0yOflNTgeZzvz m7+ND4nXPFag+f7IHopRYI/d6lR7QjxP1ZqaPJcCu7wYcczC3oBa9zxhYPUFejE//IBTyoT/gxQ0h Nkmih8AA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZK-004C36-56; Wed, 18 May 2022 22:55:02 +0000 Received: from out03.mta.xmission.com ([166.70.13.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZH-004C0s-Kg for linux-um@lists.infradead.org; Wed, 18 May 2022 22:55:00 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:33018) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZG-00CkZV-Mj; Wed, 18 May 2022 16:54:58 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZF-002Z0O-HE; Wed, 18 May 2022 16:54:58 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:48 -0500 Message-Id: <20220518225355.784371-9-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZF-002Z0O-HE; ; ; mid=<20220518225355.784371-9-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX19tbqiOJHWnZVuKgNQ7Jp3oXCI1nNuPXUo= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: **** X-Spam-Status: No, score=4.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TooManySym_01,XMNoVowels, XMSubLong,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 2.5 XM_SPF_SoftFail SPF-SoftFail * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 362 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 12 (3.3%), b_tie_ro: 10 (2.9%), parse: 1.08 (0.3%), extract_message_metadata: 12 (3.3%), get_uri_detail_list: 1.12 (0.3%), tests_pri_-1000: 15 (4.3%), tests_pri_-950: 1.19 (0.3%), tests_pri_-900: 1.06 (0.3%), tests_pri_-90: 80 (22.0%), check_bayes: 78 (21.5%), b_tokenize: 8 (2.3%), b_tok_get_all: 8 (2.3%), b_comp_prob: 2.3 (0.6%), b_tok_touch_all: 55 (15.3%), b_finish: 0.98 (0.3%), tests_pri_0: 227 (62.7%), check_dkim_signature: 0.50 (0.1%), check_dkim_adsp: 4.3 (1.2%), poll_dns_idle: 2.6 (0.7%), tests_pri_10: 2.3 (0.6%), tests_pri_500: 7 (2.0%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 09/16] ptrace: In ptrace_setsiginfo deal with invalid si_signo 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155459_699857_0EB5CEFB X-CRM114-Status: GOOD ( 12.41 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: If the tracer calls PTRACE_SETSIGINFO it only has an effect if the tracee is stopped in ptrace_signal. When one of PTRACE_DETACH, PTRACE_SINGLESTEP, PTRACE_SINGLEBLOCK, PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, PTRACE_SYSCALL, or PTRACE_CONT pass in a signel number to continue with the kernel validates [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.233 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org If the tracer calls PTRACE_SETSIGINFO it only has an effect if the tracee is stopped in ptrace_signal. When one of PTRACE_DETACH, PTRACE_SINGLESTEP, PTRACE_SINGLEBLOCK, PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, PTRACE_SYSCALL, or PTRACE_CONT pass in a signel number to continue with the kernel validates that signal number and the ptrace_signal verifies the signal number matches the si_signo, before the siginfo is used. As the signal number to continue with is verified to be a valid signal number the signal number in si_signo must be a valid signal number. Make this obvious and avoid needing checks later by immediately clearing siginfo if si_signo is not valid. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index a24eed725cec..a0a07d140751 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -716,7 +716,9 @@ static int ptrace_setsiginfo(struct task_struct *child, const kernel_siginfo_t * if (unlikely(!child->last_siginfo)) return -EINVAL; - copy_siginfo(child->last_siginfo, info); + clear_siginfo(child->last_siginfo); + if (valid_signal(info->si_signo)) + copy_siginfo(child->last_siginfo, info); return 0; } From patchwork Wed May 18 22:53:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=d6shTc/3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3SxW4hCBz9vDx for ; Thu, 19 May 2022 08:55:11 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8rldOJWruLBdX7ABYA2GKJiW/XzKIXi9opzlNn7jxTQ=; b=d6shTc/3KkOnuTTV8joYOeW/g+ J3TybIfRBunL/kl4NwkAVSunLLIOr6UtJXk5OU/sE50FJepC2xkDS3Cx4YGwVhQ28TDBmC4Zu4NdW lbtX3OkBu/rY/fpPvZDTo50JIIoict425mwM0XgITqDh11XPCYKRP1aSi5RPV+dpjGpZmr+tIuhFc W2HAAbRkTXIStG4y3e/+nUCenIx9Absotkx3P26gCX1gh81sL9zt+gud+jDaLL1oXFYyaUWrpGfSh ++2ofxeDLe8I/wwDfXD0CRFOJNSroWDrDBCasU6AFrxpm4sGdvkge9u74SZTCVplu4Wpqcah+XCdl 7PoPT9/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZN-004C5S-Fw; Wed, 18 May 2022 22:55:05 +0000 Received: from out01.mta.xmission.com ([166.70.13.231]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZL-004C41-DS for linux-um@lists.infradead.org; Wed, 18 May 2022 22:55:04 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:55170) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZK-001T8Y-Fv; Wed, 18 May 2022 16:55:02 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZJ-002Z0O-E4; Wed, 18 May 2022 16:55:02 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:49 -0500 Message-Id: <20220518225355.784371-10-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZJ-002Z0O-E4; ; ; mid=<20220518225355.784371-10-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX1+msBsnMWwqD43ol0tBZ0Atn/7Xdy2Pjbs= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa01.xmission.com X-Spam-Level: **** X-Spam-Status: No, score=4.7 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TooManySym_01,XMNoVowels, XMSubLong,XM_B_SpammyWords,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Virus: No X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa01 1397; Body=1 Fuz1=1 Fuz2=1] * 0.2 XM_B_SpammyWords One or more commonly used spammy words * 0.0 T_TooManySym_01 4+ unique symbols in subject * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 2.5 XM_SPF_SoftFail SPF-SoftFail X-Spam-DCC: XMission; sa01 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 358 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 4.6 (1.3%), b_tie_ro: 3.1 (0.9%), parse: 1.20 (0.3%), extract_message_metadata: 11 (3.0%), get_uri_detail_list: 1.09 (0.3%), tests_pri_-1000: 12 (3.3%), tests_pri_-950: 1.08 (0.3%), tests_pri_-900: 0.86 (0.2%), tests_pri_-90: 67 (18.8%), check_bayes: 66 (18.4%), b_tokenize: 6 (1.8%), b_tok_get_all: 8 (2.1%), b_comp_prob: 1.98 (0.6%), b_tok_touch_all: 47 (13.1%), b_finish: 0.78 (0.2%), tests_pri_0: 247 (68.9%), check_dkim_signature: 0.38 (0.1%), check_dkim_adsp: 2.6 (0.7%), poll_dns_idle: 1.27 (0.4%), tests_pri_10: 2.8 (0.8%), tests_pri_500: 8 (2.3%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 10/16] ptrace: In ptrace_signal look at what the debugger did with siginfo 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155503_481505_CD93700E X-CRM114-Status: GOOD ( 11.24 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Now that siginfo is only modified by the tracer and that siginfo is cleared with the signal is canceled have ptrace_signal directly examine siginfo. This makes the code a little simpler and handles the case when the tracer exits without calling ptrace_detach. Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [166.70.13.231 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.231 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Now that siginfo is only modified by the tracer and that siginfo is cleared with the signal is canceled have ptrace_signal directly examine siginfo. This makes the code a little simpler and handles the case when the tracer exits without calling ptrace_detach. Signed-off-by: "Eric W. Biederman" --- kernel/signal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/signal.c b/kernel/signal.c index ff4a52352390..3d955c23b13d 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2556,9 +2556,10 @@ static int ptrace_signal(int signr, kernel_siginfo_t *info, enum pid_type type) * comment in dequeue_signal(). */ current->jobctl |= JOBCTL_STOP_DEQUEUED; - signr = ptrace_stop(signr, CLD_TRAPPED, 0, info); + ptrace_stop(signr, CLD_TRAPPED, 0, info); /* We're back. Did the debugger cancel the sig? */ + signr = info->si_signo; if (signr == 0) return signr; From patchwork Wed May 18 22:53:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ZStyl2Bi; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3Sxd0Vlpz9vDx for ; Thu, 19 May 2022 08:55:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=N0DP60j/SPnJYHZG1mnmOpmEVDHgsjlyIPRg+vm3C/U=; b=ZStyl2BiCvVx6lq+J9xHHIAR1d YSxkKhjY43moLfqlCNXomecOQQUK2VgGp7fApUrs1wXnQN6a6gWMhnCpPyG/ZvoQAemj75uR2IDYX /IjqsA5ctCc/RMLPD4N3TglbWimxoZc2mKyllw4X7nCqdlqjCzI9kQ3mTJD6Q/SpcnNWEuspKkfkw ndm3baHzepvxrHJT3inzJ/gCv5naPWQi+fqCtYfacDnhwD7t6D+7rgzm6/flvVhtJzvT9fjgOE7oi FaIlvQsm5e+UuDK6V4p+pXzis1CYk0lYTVzmG66C0WLLhAj03VO+L5MNZV37Ie11IIWmgyk07MZnT MOc1ifOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZR-004C8V-Pv; Wed, 18 May 2022 22:55:09 +0000 Received: from out03.mta.xmission.com ([166.70.13.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZP-004C6y-9x for linux-um@lists.infradead.org; Wed, 18 May 2022 22:55:08 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:33160) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZO-00CkbE-8F; Wed, 18 May 2022 16:55:06 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZN-002Z0O-3U; Wed, 18 May 2022 16:55:05 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:50 -0500 Message-Id: <20220518225355.784371-11-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZN-002Z0O-3U; ; ; mid=<20220518225355.784371-11-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX1+rSJyO1oyZx6lyj4Wo/uKq27rq9xXwpb0= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa03.xmission.com X-Spam-Level: **** X-Spam-Status: No, score=4.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TooManySym_01,XMNoVowels, XMSubLong,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Virus: No X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa03 1397; Body=1 Fuz1=1 Fuz2=1] * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 2.5 XM_SPF_SoftFail SPF-SoftFail * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 456 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 4.7 (1.0%), b_tie_ro: 3.2 (0.7%), parse: 1.32 (0.3%), extract_message_metadata: 11 (2.3%), get_uri_detail_list: 2.6 (0.6%), tests_pri_-1000: 12 (2.6%), tests_pri_-950: 0.99 (0.2%), tests_pri_-900: 0.84 (0.2%), tests_pri_-90: 58 (12.6%), check_bayes: 57 (12.4%), b_tokenize: 9 (1.9%), b_tok_get_all: 9 (2.0%), b_comp_prob: 1.89 (0.4%), b_tok_touch_all: 34 (7.4%), b_finish: 0.67 (0.1%), tests_pri_0: 358 (78.4%), check_dkim_signature: 0.41 (0.1%), check_dkim_adsp: 1.66 (0.4%), poll_dns_idle: 0.33 (0.1%), tests_pri_10: 1.69 (0.4%), tests_pri_500: 6 (1.3%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 11/16] ptrace: Use si_sino as the signal number to resume with 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155507_356072_D63090CD X-CRM114-Status: GOOD ( 18.05 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The signal number to resume with is already in si_signo. So instead of placing an extra copy in tsk->exit_code and later reading the extra copy from tsk->exit_code just read si_signo. Read si_signo in ptrace_do_notify where it is easy as the siginfo is a local variable. Only ptrace_report_syscall cares about the signal to resume with from ptrace_stop and it calls ptrace_notify whic [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.233 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The signal number to resume with is already in si_signo. So instead of placing an extra copy in tsk->exit_code and later reading the extra copy from tsk->exit_code just read si_signo. Read si_signo in ptrace_do_notify where it is easy as the siginfo is a local variable. Only ptrace_report_syscall cares about the signal to resume with from ptrace_stop and it calls ptrace_notify which calls ptrace_do_notify so moving the actual work into ptrace_do_notify where it is easier is not a problem. With ptrace_stop not being involved in returning the signal to tracer asked the tracee to resume with remove the comment and the return code from ptrace_stop. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 1 - kernel/signal.c | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index a0a07d140751..e0ecb1536dfc 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -530,7 +530,6 @@ static void ptrace_set_signr(struct task_struct *child, unsigned int signr) { struct kernel_siginfo *info = child->last_siginfo; - child->exit_code = signr; /* * Update the siginfo structure if the signal has * changed. If the debugger wanted something diff --git a/kernel/signal.c b/kernel/signal.c index 3d955c23b13d..2cc45e8448e2 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2186,12 +2186,8 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, * We always set current->last_siginfo while stopped here. * That makes it a way to test a stopped process for * being ptrace-stopped vs being job-control-stopped. - * - * Returns the signal the ptracer requested the code resume - * with. If the code did not stop because the tracer is gone, - * the stop signal remains unchanged unless clear_code. */ -static int ptrace_stop(int exit_code, int why, unsigned long message, +static void ptrace_stop(int exit_code, int why, unsigned long message, kernel_siginfo_t *info) __releases(¤t->sighand->siglock) __acquires(¤t->sighand->siglock) @@ -2219,7 +2215,7 @@ static int ptrace_stop(int exit_code, int why, unsigned long message, * signals here to prevent ptrace_stop sleeping in schedule. */ if (!current->ptrace || __fatal_signal_pending(current)) - return exit_code; + return; set_special_state(TASK_TRACED); current->jobctl |= JOBCTL_TRACED; @@ -2302,7 +2298,6 @@ static int ptrace_stop(int exit_code, int why, unsigned long message, * any signal-sending on another CPU that wants to examine it. */ spin_lock_irq(¤t->sighand->siglock); - exit_code = current->exit_code; current->last_siginfo = NULL; current->ptrace_message = 0; current->exit_code = 0; @@ -2316,7 +2311,6 @@ static int ptrace_stop(int exit_code, int why, unsigned long message, * This sets TIF_SIGPENDING, but never clears it. */ recalc_sigpending_tsk(current); - return exit_code; } static int ptrace_do_notify(int signr, int exit_code, int why, unsigned long message) @@ -2330,7 +2324,8 @@ static int ptrace_do_notify(int signr, int exit_code, int why, unsigned long mes info.si_uid = from_kuid_munged(current_user_ns(), current_uid()); /* Let the debugger run. */ - return ptrace_stop(exit_code, why, message, &info); + ptrace_stop(exit_code, why, message, &info); + return info.si_signo; } int ptrace_notify(int exit_code, unsigned long message) From patchwork Wed May 18 22:53:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632998 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=MRLQM2x2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3Sxj1jrXz9vDx for ; Thu, 19 May 2022 08:55:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=w5zjwt4lr7WZIix3sjR7RikRXp4WIGyqcFrTWHQPk5I=; b=MRLQM2x242yPv24MqvIwP+8XGH uq/0l5DN6DmYQa8UvOTG7N5axajMPjB163DHmkEoYMm9SBAYoAodkLbcNwmGQvkC7g9Ghjl8ONL/f 9zgRogu2VUzDzL2Pxrqu64YUGlS6bNoXuKRJOjeoMADdW34m5UJBtyuwoDkjdfHHzQdWsFl4Vw+G5 XRifqr5IfLEHul7UviD29LEzo7DbuS7gGAKqY9YyKkdkUKgohIZsMHGM8SU0Uzz/oGQv5YmCmQVzc +QY0CZoOSqERnt6YFQBgmNA9eBW/Ikt9ndDDp9LFZL62tsriwS8umu3uTsIB86690VxJZVkXBuNpP 8HXyIbFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZW-004CBw-8k; Wed, 18 May 2022 22:55:14 +0000 Received: from out02.mta.xmission.com ([166.70.13.232]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZT-004C9R-2Q for linux-um@lists.infradead.org; Wed, 18 May 2022 22:55:12 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:55458) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZS-003beY-66; Wed, 18 May 2022 16:55:10 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZQ-002Z0O-Rs; Wed, 18 May 2022 16:55:09 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:51 -0500 Message-Id: <20220518225355.784371-12-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZQ-002Z0O-Rs; ; ; mid=<20220518225355.784371-12-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX1+6ZglDwrAlEIdCQnkjVs1exKPzXqw2e04= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa05.xmission.com X-Spam-Level: ***** X-Spam-Status: No, score=5.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,XMNoVowels,XMSubLong, XM_Body_Dirty_Words,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa05 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 2.5 XM_SPF_SoftFail SPF-SoftFail * 1.0 XM_Body_Dirty_Words Contains a dirty word X-Spam-DCC: XMission; sa05 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *****;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 730 ms - load_scoreonly_sql: 0.11 (0.0%), signal_user_changed: 14 (1.9%), b_tie_ro: 12 (1.6%), parse: 2.1 (0.3%), extract_message_metadata: 19 (2.6%), get_uri_detail_list: 2.4 (0.3%), tests_pri_-1000: 23 (3.1%), tests_pri_-950: 1.71 (0.2%), tests_pri_-900: 1.57 (0.2%), tests_pri_-90: 279 (38.2%), check_bayes: 276 (37.9%), b_tokenize: 18 (2.4%), b_tok_get_all: 171 (23.5%), b_comp_prob: 4.8 (0.7%), b_tok_touch_all: 78 (10.7%), b_finish: 1.24 (0.2%), tests_pri_0: 367 (50.2%), check_dkim_signature: 0.76 (0.1%), check_dkim_adsp: 4.5 (0.6%), poll_dns_idle: 1.17 (0.2%), tests_pri_10: 2.4 (0.3%), tests_pri_500: 15 (2.0%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 12/16] ptrace: Stop protecting ptrace_set_signr with tasklist_lock 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155511_140903_BA19266E X-CRM114-Status: GOOD ( 12.95 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Now that ptrace_set_signr no longer sets task->exit_code the race documented in commit b72c186999e6 ("ptrace: fix race between ptrace_resume() and wait_task_stopped()") is no longer possible, as task- [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [166.70.13.232 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.232 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Now that ptrace_set_signr no longer sets task->exit_code the race documented in commit b72c186999e6 ("ptrace: fix race between ptrace_resume() and wait_task_stopped()") is no longer possible, as task->exit_code is only updated by wait during a ptrace_stop. As there is no possibilty of a race and ptrace_freeze_traced is all of the protection ptrace_set_signr needs to operate without contention move ptrace_set_signr outside of tasklist_lock and remove the documentation about the race that is no more. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index e0ecb1536dfc..d0527b6e2b29 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -595,17 +595,14 @@ static int ptrace_detach(struct task_struct *child, unsigned int data) /* Architecture-specific hardware disable .. */ ptrace_disable(child); + ptrace_set_signr(child, data); + write_lock_irq(&tasklist_lock); /* * We rely on ptrace_freeze_traced(). It can't be killed and * untraced by another thread, it can't be a zombie. */ WARN_ON(!child->ptrace || child->exit_state); - /* - * tasklist_lock avoids the race with wait_task_stopped(), see - * the comment in ptrace_resume(). - */ - ptrace_set_signr(child, data); __ptrace_detach(current, child); write_unlock_irq(&tasklist_lock); @@ -869,17 +866,9 @@ static int ptrace_resume(struct task_struct *child, long request, user_disable_single_step(child); } - /* - * Change ->exit_code and ->state under siglock to avoid the race - * with wait_task_stopped() in between; a non-zero ->exit_code will - * wrongly look like another report from tracee. - * - * Note that we need siglock even if ->exit_code == data and/or this - * status was not reported yet, the new status must not be cleared by - * wait_task_stopped() after resume. - */ - spin_lock_irq(&child->sighand->siglock); ptrace_set_signr(child, data); + + spin_lock_irq(&child->sighand->siglock); child->jobctl &= ~JOBCTL_TRACED; wake_up_state(child, __TASK_TRACED); spin_unlock_irq(&child->sighand->siglock); From patchwork Wed May 18 22:53:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1632999 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=sWaIfhXP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3Sxl4CPzz9vDx for ; Thu, 19 May 2022 08:55:23 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=1xCS4BnLSbUSWa/z6W/tS3e+mh+nuwYd9t/Dhny/66U=; b=sWaIfhXPixYRRep5GsROVJNcax 9+AD681DZp2U0CWT9DEWq0dGQ2E7iJ/YkIR4VKEihdwNFs3Z9UTiRMDEDCIks9eILKe6+UeeR80P1 btQYCcuWfif4FGidLAPG2R4Rpkr23Kbeu1jpEINc/zLwVVnjRbgYOIO7odbVbPUjf6oo01IGRIm9q nZKRGbQ2FmeHt23VPZbpqyJKMNAu4S40TLp8p/5wCzjYYhb3xdWlLm20De5g9YmGrbqc4ctSHpkPz 6prPuuhur3qgCZjAALJdAGAeL5PHr6D/mss3llN8rHHJGhHgDqxBaIW1Yo+mUby9zO/3LEXVGKJST fVuX+4PA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZZ-004CEJ-HI; Wed, 18 May 2022 22:55:17 +0000 Received: from out02.mta.xmission.com ([166.70.13.232]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZW-004CCQ-R4 for linux-um@lists.infradead.org; Wed, 18 May 2022 22:55:16 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:55520) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZV-003bfZ-Um; Wed, 18 May 2022 16:55:13 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZU-002Z0O-Ps; Wed, 18 May 2022 16:55:13 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:52 -0500 Message-Id: <20220518225355.784371-13-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZU-002Z0O-Ps; ; ; mid=<20220518225355.784371-13-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX18zEH9NpD628NHFl0dZMZNqY3TpzcDYfhc= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa04.xmission.com X-Spam-Level: **** X-Spam-Status: No, score=4.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,XMNoVowels,XMSubLong, XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa04 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 2.5 XM_SPF_SoftFail SPF-SoftFail X-Spam-DCC: XMission; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 481 ms - load_scoreonly_sql: 0.11 (0.0%), signal_user_changed: 14 (2.9%), b_tie_ro: 12 (2.5%), parse: 1.81 (0.4%), extract_message_metadata: 19 (3.9%), get_uri_detail_list: 1.71 (0.4%), tests_pri_-1000: 23 (4.8%), tests_pri_-950: 1.74 (0.4%), tests_pri_-900: 1.47 (0.3%), tests_pri_-90: 69 (14.3%), check_bayes: 66 (13.8%), b_tokenize: 11 (2.4%), b_tok_get_all: 9 (1.8%), b_comp_prob: 3.0 (0.6%), b_tok_touch_all: 39 (8.1%), b_finish: 1.09 (0.2%), tests_pri_0: 337 (70.2%), check_dkim_signature: 0.86 (0.2%), check_dkim_adsp: 3.6 (0.7%), poll_dns_idle: 1.01 (0.2%), tests_pri_10: 2.1 (0.4%), tests_pri_500: 7 (1.4%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 13/16] ptrace: Document why ptrace_setoptions does not need a lock 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155514_920627_DBAA69EE X-CRM114-Status: GOOD ( 12.97 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The functions that change ->ptrace are: ptrace_attach, ptrace_traceme, ptrace_init_task, __ptrace_unlink, ptrace_setoptions. Except for ptrace_setoptions all of the places where ->ptrace is modified hold tasklist_lock for write, and either the tracee or the tracer is modifies ->ptrace. Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [166.70.13.232 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.232 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The functions that change ->ptrace are: ptrace_attach, ptrace_traceme, ptrace_init_task, __ptrace_unlink, ptrace_setoptions. Except for ptrace_setoptions all of the places where ->ptrace is modified hold tasklist_lock for write, and either the tracee or the tracer is modifies ->ptrace. When ptrace_setoptions is called the tracee has been frozen with ptrace_freeze_traced, and most be explicitly unfrozen by the tracer before it can do anything. As ptrace_setoption is run in the tracer there can be no contention by the simple fact that the tracee can't run. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index d0527b6e2b29..fbadd2f21f09 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -689,7 +689,10 @@ static int ptrace_setoptions(struct task_struct *child, unsigned long data) if (ret) return ret; - /* Avoid intermediate state when all opts are cleared */ + /* + * With a frozen tracee, only the tracer modifies ->ptrace. + * Avoid intermediate state when all opts are cleared. + */ flags = child->ptrace; flags &= ~(PTRACE_O_MASK << PT_OPT_FLAG_SHIFT); flags |= (data << PT_OPT_FLAG_SHIFT); From patchwork Wed May 18 22:53:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1633000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=0wVJ1kEd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3Sxr11bQz9vDx for ; Thu, 19 May 2022 08:55:28 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Z+VhdxImUpFl6ngegAO4X0xt7to2KZq4WGmPgUiArzo=; b=0wVJ1kEdQuMhHpanChyB0MBUCj Aatd6/4Fgb7dMR0I4aZF2hjGgLsAUbLlBMyeHH5/PbDNcIh868TCfPd4/KxA+HG3M9Wo+OHpnPKrX yzLnAMonG7YPuzm/K8+aYCg6YtywXLtpLQ7UWLVN8JnyyBbt85w+FFORli7gh4YIEtL6R61WeQVuU FE+HyXTtR44GM2WQRzI6mm6fyHdKfttOWSUYkj38qJwiaDb3afZmUCZYNLDw482KWgXXweLchenkp 6lDN2r7DyCbYKZ/l2N6vTk5670wcGJHl0x1vIl21hslbgZD0jLhhF/SkzNVpyHcoNc61BoExKqX8r T+9NRWLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZd-004CHW-SJ; Wed, 18 May 2022 22:55:21 +0000 Received: from out02.mta.xmission.com ([166.70.13.232]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZa-004CFa-U6 for linux-um@lists.infradead.org; Wed, 18 May 2022 22:55:20 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:55588) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZZ-003bgl-Vq; Wed, 18 May 2022 16:55:18 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZY-002Z0O-My; Wed, 18 May 2022 16:55:17 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:53 -0500 Message-Id: <20220518225355.784371-14-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZY-002Z0O-My; ; ; mid=<20220518225355.784371-14-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX19FLqwrnq1bvGioZrorhislxB7aEEARHFA= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa06.xmission.com X-Spam-Level: ****** X-Spam-Status: No, score=6.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,XMNoVowels,XMSubLong, XMSubMetaSx_00,XM_B_Investor,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.0 XM_B_Investor BODY: Commonly used business phishing phrases * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 1.0 XMSubMetaSx_00 1+ Sexy Words * 2.5 XM_SPF_SoftFail SPF-SoftFail X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ******;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 637 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 11 (1.8%), b_tie_ro: 10 (1.5%), parse: 1.19 (0.2%), extract_message_metadata: 12 (1.9%), get_uri_detail_list: 2.2 (0.3%), tests_pri_-1000: 18 (2.9%), tests_pri_-950: 1.28 (0.2%), tests_pri_-900: 1.05 (0.2%), tests_pri_-90: 156 (24.5%), check_bayes: 155 (24.3%), b_tokenize: 13 (2.1%), b_tok_get_all: 12 (1.9%), b_comp_prob: 3.3 (0.5%), b_tok_touch_all: 121 (19.0%), b_finish: 1.03 (0.2%), tests_pri_0: 416 (65.3%), check_dkim_signature: 0.59 (0.1%), check_dkim_adsp: 2.9 (0.5%), poll_dns_idle: 0.94 (0.1%), tests_pri_10: 2.3 (0.4%), tests_pri_500: 14 (2.2%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 14/16] signal: Protect parent child relationships by childs siglock 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155519_037343_147B48A2 X-CRM114-Status: GOOD ( 14.45 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The functions ptrace_stop and do_signal_stop have to drop siglock and grab tasklist_lock because the parent/child relation ship is guarded by tasklist_lock and not siglock. Simplify things by additionally guarding the parent/child relationship with siglock. This just requires a little bit of code motion. Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [166.70.13.232 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.232 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The functions ptrace_stop and do_signal_stop have to drop siglock and grab tasklist_lock because the parent/child relation ship is guarded by tasklist_lock and not siglock. Simplify things by additionally guarding the parent/child relationship with siglock. This just requires a little bit of code motion. After this change tsk->parent, tsk->real_parent, tsk->ptracer_cred are all protected by tsk->siglock. The fields tsk->sibling and tsk->ptrace_entry are mostly protected by tsk->siglock. The field tsk->ptrace_entry is not protected by siglock when tsk->ptrace_entry is reused as the dead task list. The field tsk->sibling is not protected by siglock when children are reparented because their original parent dies. The field tsk->ptrace is protected by siglock except for the options which may change without siglock being held. Signed-off-by: "Eric W. Biederman" --- kernel/exit.c | 4 ++++ kernel/fork.c | 12 ++++++------ kernel/ptrace.c | 9 +++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index 0e26f73c49ac..bad434b23c48 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -643,11 +643,15 @@ static void forget_original_parent(struct task_struct *father, reaper = find_new_reaper(father, reaper); list_for_each_entry(p, &father->children, sibling) { + spin_lock(&p->sighand->siglock); for_each_thread(p, t) { RCU_INIT_POINTER(t->real_parent, reaper); BUG_ON((!t->ptrace) != (rcu_access_pointer(t->parent) == father)); if (likely(!t->ptrace)) t->parent = t->real_parent; + } + spin_unlock(&p->sighand->siglock); + for_each_thread(p, t) { if (t->pdeath_signal) group_send_sig_info(t->pdeath_signal, SEND_SIG_NOINFO, t, diff --git a/kernel/fork.c b/kernel/fork.c index 9796897560ab..841021da69f3 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2367,6 +2367,12 @@ static __latent_entropy struct task_struct *copy_process( */ write_lock_irq(&tasklist_lock); + klp_copy_process(p); + + sched_core_fork(p); + + spin_lock(¤t->sighand->siglock); + /* CLONE_PARENT re-uses the old parent */ if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) { p->real_parent = current->real_parent; @@ -2381,12 +2387,6 @@ static __latent_entropy struct task_struct *copy_process( p->exit_signal = args->exit_signal; } - klp_copy_process(p); - - sched_core_fork(p); - - spin_lock(¤t->sighand->siglock); - /* * Copy seccomp details explicitly here, in case they were changed * before holding sighand lock. diff --git a/kernel/ptrace.c b/kernel/ptrace.c index fbadd2f21f09..77dfdb3d1ced 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -123,13 +123,12 @@ void __ptrace_unlink(struct task_struct *child) clear_task_syscall_work(child, SYSCALL_EMU); #endif + spin_lock(&child->sighand->siglock); child->parent = child->real_parent; list_del_init(&child->ptrace_entry); old_cred = child->ptracer_cred; child->ptracer_cred = NULL; put_cred(old_cred); - - spin_lock(&child->sighand->siglock); child->ptrace = 0; /* * Clear all pending traps and TRAPPING. TRAPPING should be @@ -441,15 +440,15 @@ static int ptrace_attach(struct task_struct *task, long request, if (task->ptrace) goto unlock_tasklist; + spin_lock(&task->sighand->siglock); task->ptrace = flags; ptrace_link(task, current); /* SEIZE doesn't trap tracee on attach */ if (!seize) - send_sig_info(SIGSTOP, SEND_SIG_PRIV, task); + send_signal_locked(SIGSTOP, SEND_SIG_PRIV, task, PIDTYPE_PID); - spin_lock(&task->sighand->siglock); /* * If the task is already STOPPED, set JOBCTL_TRAP_STOP and @@ -517,8 +516,10 @@ static int ptrace_traceme(void) * pretend ->real_parent untraces us right after return. */ if (!ret && !(current->real_parent->flags & PF_EXITING)) { + spin_lock(¤t->sighand->siglock); current->ptrace = PT_PTRACED; ptrace_link(current, current->real_parent); + spin_unlock(¤t->sighand->siglock); } } write_unlock_irq(&tasklist_lock); From patchwork Wed May 18 22:53:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1633001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=BjOBclr+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3Sxx2cKGz9vDx for ; Thu, 19 May 2022 08:55:33 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=KiWVr+qM5KX0htPKX/i+U01kxRPDz1rgsgS1vZoDGdw=; b=BjOBclr+h663R8qLjmmVzxaujA K2rylGJbQ+S5U77X4IeKLhwkD9nHeC1S0lwZr/QttL+6c71K2vEScnGuMqMwxV2OyEc+8HzNK6gal lp5fLdp1MgQQdEDBCBQojuewZiOfHg8vMs0D2XYIC8JmQQOmDj3IwVWfEvobYrFKkJ41Vq6R7peEz p1AUtiKM0n8lVuEtfZddPcLTeJfpt5NakJmu2YOX+zmji57uY07MNG8hZimM6bMm2Tx/dyhtZ8U03 0lsvmnEJWANCOH2UtgQsc2P79/IL+3M+/wj/RWpLqHvLvViWT4v1yCy3ooEBHZDEsWPbqkzlCL6d1 PIC5asQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZi-004CKK-3T; Wed, 18 May 2022 22:55:26 +0000 Received: from out03.mta.xmission.com ([166.70.13.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZe-004CI4-RN for linux-um@lists.infradead.org; Wed, 18 May 2022 22:55:24 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:33438) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZd-00Ckcv-Nn; Wed, 18 May 2022 16:55:21 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZc-002Z0O-KW; Wed, 18 May 2022 16:55:21 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:54 -0500 Message-Id: <20220518225355.784371-15-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZc-002Z0O-KW; ; ; mid=<20220518225355.784371-15-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX19BX42rXAmEdeldIBaC1nvKtXoRgWt4/eg= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa04.xmission.com X-Spam-Level: ***** X-Spam-Status: No, score=5.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,XMNoVowels,XMSubLong, XM_Body_Dirty_Words,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa04 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 2.5 XM_SPF_SoftFail SPF-SoftFail * 1.0 XM_Body_Dirty_Words Contains a dirty word X-Spam-DCC: XMission; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *****;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 473 ms - load_scoreonly_sql: 0.10 (0.0%), signal_user_changed: 14 (3.0%), b_tie_ro: 12 (2.5%), parse: 2.0 (0.4%), extract_message_metadata: 19 (4.0%), get_uri_detail_list: 2.4 (0.5%), tests_pri_-1000: 23 (4.8%), tests_pri_-950: 1.71 (0.4%), tests_pri_-900: 1.47 (0.3%), tests_pri_-90: 64 (13.5%), check_bayes: 62 (13.1%), b_tokenize: 13 (2.7%), b_tok_get_all: 8 (1.6%), b_comp_prob: 3.2 (0.7%), b_tok_touch_all: 35 (7.4%), b_finish: 0.87 (0.2%), tests_pri_0: 321 (67.8%), check_dkim_signature: 0.97 (0.2%), check_dkim_adsp: 3.5 (0.7%), poll_dns_idle: 0.92 (0.2%), tests_pri_10: 2.2 (0.5%), tests_pri_500: 20 (4.2%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 15/16] ptrace: Use siglock instead of tasklist_lock in ptrace_check_attach 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155522_947264_5695BD40 X-CRM114-Status: GOOD ( 13.64 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Now that siglock protects tsk->parent and tsk->ptrace there is no need to grab tasklist_lock in ptrace_check_attach. The siglock can handle all of the locking needs of ptrace_check_attach. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 23 +++++++++ 1 file changed, 9 insertions(+), 14 deletions(-) Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.233 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Now that siglock protects tsk->parent and tsk->ptrace there is no need to grab tasklist_lock in ptrace_check_attach. The siglock can handle all of the locking needs of ptrace_check_attach. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 77dfdb3d1ced..fa65841bbdbe 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -194,17 +194,14 @@ static bool ptrace_freeze_traced(struct task_struct *task) { bool ret = false; - /* Lockless, nobody but us can set this flag */ if (task->jobctl & JOBCTL_LISTENING) return ret; - spin_lock_irq(&task->sighand->siglock); if (task_is_traced(task) && !looks_like_a_spurious_pid(task) && !__fatal_signal_pending(task)) { task->jobctl |= JOBCTL_PTRACE_FROZEN; ret = true; } - spin_unlock_irq(&task->sighand->siglock); return ret; } @@ -240,32 +237,30 @@ static void ptrace_unfreeze_traced(struct task_struct *task) * state. * * CONTEXT: - * Grabs and releases tasklist_lock and @child->sighand->siglock. + * Grabs and releases @child->sighand->siglock. * * RETURNS: * 0 on success, -ESRCH if %child is not ready. */ static int ptrace_check_attach(struct task_struct *child, bool ignore_state) { + unsigned long flags; int ret = -ESRCH; /* - * We take the read lock around doing both checks to close a + * We take the siglock around doing both checks to close a * possible race where someone else was tracing our child and * detached between these two checks. After this locked check, * we are sure that this is our traced child and that can only * be changed by us so it's not changing right after this. */ - read_lock(&tasklist_lock); - if (child->ptrace && child->parent == current) { - /* - * child->sighand can't be NULL, release_task() - * does ptrace_unlink() before __exit_signal(). - */ - if (ignore_state || ptrace_freeze_traced(child)) - ret = 0; + if (lock_task_sighand(child, &flags)) { + if (child->ptrace && child->parent == current) { + if (ignore_state || ptrace_freeze_traced(child)) + ret = 0; + } + unlock_task_sighand(child, &flags); } - read_unlock(&tasklist_lock); if (!ret && !ignore_state && WARN_ON_ONCE(!wait_task_inactive(child, __TASK_TRACED))) From patchwork Wed May 18 22:53:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 1633002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=l0Z8D7Ns; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3Sy20GXLz9vDx for ; Thu, 19 May 2022 08:55:37 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=EzbcTGDp5Plpj1vh8W2tbrCKEFGURW8dItgqq6t6Jm4=; b=l0Z8D7Ns9ovM9C/2Hcp/q4QYc+ SES+/7bevw3eeqtE3VmN+GzRa9qgkNFnNOzWipS6GfQJahF5NqMCqzCqRNkPQCDCxHJKS5DdFfYQ7 ZGB2O6gk0lKpJqxwmoRWqX+pbe9rJrAeDQUuK+x5JqRXE2v/+ShIQH22hbH4YbdQfXlQbrymh/yZ5 IHypNWqknz+a2V3l9b7/to94XFPpXJto01StXdfsiwMMIfzcoAesISDQpTn1fkJtC2Ic6nEkVTMbf e2RXIl6y8Y4XK92q/TXzItA6B0y4V4fIk5O94WPPbLAYKIfHiL1hnMhAgvXtchd7bn/b7g9JRj08C 7gf18hLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZn-004CNV-E2; Wed, 18 May 2022 22:55:31 +0000 Received: from out02.mta.xmission.com ([166.70.13.232]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrSZj-004CKr-34 for linux-um@lists.infradead.org; Wed, 18 May 2022 22:55:29 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]:55710) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZi-003bi7-66; Wed, 18 May 2022 16:55:26 -0600 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:38724 helo=localhost.localdomain) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrSZg-002Z0O-BI; Wed, 18 May 2022 16:55:25 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, Oleg Nesterov , 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 , linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linux-ia64@vger.kernel.org, Robert OCallahan , Kyle Huey , Richard Henderson , Ivan Kokshaysky , Matt Turner , Jason Wessel , Daniel Thompson , Douglas Anderson , Douglas Miller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Eric W. Biederman" Date: Wed, 18 May 2022 17:53:55 -0500 Message-Id: <20220518225355.784371-16-ebiederm@xmission.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> References: <871qwq5ucx.fsf_-_@email.froward.int.ebiederm.org> MIME-Version: 1.0 X-XM-SPF: eid=1nrSZg-002Z0O-BI; ; ; mid=<20220518225355.784371-16-ebiederm@xmission.com>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.174.4; ; ; frm=ebiederm@xmission.com; ; ; spf=softfail X-XM-AID: U2FsdGVkX19tGoXERnofsWkaefTR9KA1SSKryl+GXsQ= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa06.xmission.com X-Spam-Level: ******* X-Spam-Status: No, score=7.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_SCC_BODY_TEXT_LINE,T_TooManySym_01,XMGappySubj_01, XMNoVowels,XMSubLong,XM_B_Investor,XM_Body_Dirty_Words,XM_SPF_SoftFail autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.0 XM_B_Investor BODY: Commonly used business phishing phrases * 0.7 XMSubLong Long Subject * 0.5 XMGappySubj_01 Very gappy subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * -0.0 T_SCC_BODY_TEXT_LINE No description available. * 1.0 XM_Body_Dirty_Words Contains a dirty word * 0.0 T_TooManySym_01 4+ unique symbols in subject * 2.5 XM_SPF_SoftFail SPF-SoftFail X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *******;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 1131 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 9 (0.8%), b_tie_ro: 8 (0.7%), parse: 2.3 (0.2%), extract_message_metadata: 19 (1.7%), get_uri_detail_list: 8 (0.7%), tests_pri_-1000: 15 (1.4%), tests_pri_-950: 1.29 (0.1%), tests_pri_-900: 1.06 (0.1%), tests_pri_-90: 205 (18.1%), check_bayes: 204 (18.0%), b_tokenize: 25 (2.2%), b_tok_get_all: 15 (1.3%), b_comp_prob: 4.4 (0.4%), b_tok_touch_all: 155 (13.7%), b_finish: 0.95 (0.1%), tests_pri_0: 861 (76.1%), check_dkim_signature: 0.79 (0.1%), check_dkim_adsp: 2.6 (0.2%), poll_dns_idle: 0.85 (0.1%), tests_pri_10: 2.9 (0.3%), tests_pri_500: 10 (0.9%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 16/16] 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_155527_208593_4E336C60 X-CRM114-Status: GOOD ( 29.18 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Now that siglock keeps tsk->parent and tsk->real_parent constant require that do_notify_parent_cldstop is called with tsk->siglock held instead of the tasklist_lock. As all of the callers of do_notify_parent_cldstop had to drop the siglock and take tasklist_lock this simplifies all of it's callers. Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [166.70.13.232 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [166.70.13.232 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Now that siglock keeps tsk->parent and tsk->real_parent constant require that do_notify_parent_cldstop is called with tsk->siglock held instead of the tasklist_lock. As all of the callers of do_notify_parent_cldstop had to drop the siglock and take tasklist_lock this simplifies all of it's callers. This removes one reason for taking tasklist_lock. This makes ptrace_stop so that it should reliably work correctly and reliably with PREEMPT_RT enabled and CONFIG_CGROUPS disabled. The remaining challenge is that cgroup_enter_frozen takes spin_lock after __state has been set to TASK_TRACED. Which on PREEMPT_RT means the code can sleep and change __state. Not only that but it means that wait_task_inactive could potentially detect the code scheduling away at that point and fail, causing ptrace_check_attach to fail. Signed-off-by: "Eric W. Biederman" Reported-by: kernel test robot --- kernel/signal.c | 262 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 189 insertions(+), 73 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 2cc45e8448e2..d4956be51939 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1994,6 +1994,129 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type) return ret; } +/** + * lock_parents_siglocks - Take current, real_parent, and parent's siglock + * @lock_tracer: The tracers siglock is needed. + * + * There is no natural ordering to these locks so they must be sorted + * before being taken. + * + * There are two complicating factors here: + * - The locks live in sighand and sighand can be arbitrarily shared + * - parent and real_parent can change when current's siglock is unlocked. + * + * To deal with this first the all of the sighand pointers are + * gathered under current's siglock, and the sighand pointers are + * sorted. As siglock lives inside of sighand this also sorts the + * siglock's by address. + * + * Then the siglocks are taken in order dropping current's siglock if + * necessary. + * + * Finally if parent and real_parent have not changed return. + * If they either parent has changed drop their locks and try again. + * + * Changing sighand is an infrequent and somewhat expensive operation + * (unshare or exec) and so even in the worst case this loop + * should not loop too many times before all of the proper locks are + * taken in order. + * + * CONTEXT: + * Must be called with @current->sighand->siglock held + * + * RETURNS: + * current's, real_parent's, and parent's siglock held. + */ +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 = ptrace_parent(me); + if (!tracer || !lock_tracer) + tracer = 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); + + /* Take the locks in order */ + if (s1 != m_sighand) { + spin_unlock(&m_sighand->siglock); + spin_lock(&s1->siglock); + } + if (s1 != s2) + spin_lock_nested(&s2->siglock, 1); + if (s2 != s3) + spin_lock_nested(&s3->siglock, 2); + + /* Verify the proper locks are held */ + if (likely((s1 == m_sighand) || + ((me->real_parent == parent) && + (me->parent == tracer) && + (parent->sighand == p_sighand) && + (tracer->sighand == t_sighand)))) { + break; + } + + /* Drop all but current's siglock */ + if (p_sighand != m_sighand) + spin_unlock(&p_sighand->siglock); + if (t_sighand != p_sighand) + spin_unlock(&t_sighand->siglock); + + /* + * 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.dep_map, 0, _RET_IP_); + } + rcu_read_unlock(); +} + +static void unlock_parents_siglocks(bool unlock_tracer) + __releases(¤t->real_parent->sighand->siglock) + __releases(¤t->parent->sighand->siglock) +{ + struct task_struct *me = current; + struct task_struct *parent = me->real_parent; + struct task_struct *tracer = ptrace_parent(me); + struct sighand_struct *m_sighand = me->sighand; + struct sighand_struct *p_sighand = parent->sighand; + + if (p_sighand != m_sighand) + spin_unlock(&p_sighand->siglock); + if (tracer && unlock_tracer) { + struct sighand_struct *t_sighand = tracer->sighand; + if (t_sighand != p_sighand) + spin_unlock(&t_sighand->siglock); + } +} + static void do_notify_pidfd(struct task_struct *task) { struct pid *pid; @@ -2125,11 +2248,12 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, bool for_ptracer, int why) { struct kernel_siginfo info; - unsigned long flags; struct task_struct *parent; struct sighand_struct *sighand; u64 utime, stime; + lockdep_assert_held(&tsk->sighand->siglock); + if (for_ptracer) { parent = tsk->parent; } else { @@ -2137,6 +2261,8 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, parent = tsk->real_parent; } + lockdep_assert_held(&parent->sighand->siglock); + clear_siginfo(&info); info.si_signo = SIGCHLD; info.si_errno = 0; @@ -2168,7 +2294,6 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, } sighand = parent->sighand; - spin_lock_irqsave(&sighand->siglock, flags); if (sighand->action[SIGCHLD-1].sa.sa_handler != SIG_IGN && !(sighand->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP)) send_signal_locked(SIGCHLD, &info, parent, PIDTYPE_TGID); @@ -2176,7 +2301,6 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, * Even if SIGCHLD is not generated, we must wake up wait4 calls. */ __wake_up_parent(tsk, parent); - spin_unlock_irqrestore(&sighand->siglock, flags); } /* @@ -2208,14 +2332,18 @@ static void ptrace_stop(int exit_code, int why, unsigned long message, spin_lock_irq(¤t->sighand->siglock); } + lock_parents_siglocks(true); /* * After this point ptrace_signal_wake_up or signal_wake_up * will clear TASK_TRACED if ptrace_unlink happens or a fatal * signal comes in. Handle previous ptrace_unlinks and fatal * signals here to prevent ptrace_stop sleeping in schedule. */ - if (!current->ptrace || __fatal_signal_pending(current)) + + if (!current->ptrace || __fatal_signal_pending(current)) { + unlock_parents_siglocks(true); return; + } set_special_state(TASK_TRACED); current->jobctl |= JOBCTL_TRACED; @@ -2254,16 +2382,6 @@ static void ptrace_stop(int exit_code, int why, unsigned long message, if (why == CLD_STOPPED && (current->jobctl & JOBCTL_STOP_PENDING)) gstop_done = task_participate_group_stop(current); - /* any trap clears pending STOP trap, STOP trap clears NOTIFY */ - task_clear_jobctl_pending(current, JOBCTL_TRAP_STOP); - if (info && info->si_code >> 8 == PTRACE_EVENT_STOP) - task_clear_jobctl_pending(current, JOBCTL_TRAP_NOTIFY); - - /* entering a trap, clear TRAPPING */ - task_clear_jobctl_trapping(current); - - spin_unlock_irq(¤t->sighand->siglock); - read_lock(&tasklist_lock); /* * Notify parents of the stop. * @@ -2279,14 +2397,25 @@ static void ptrace_stop(int exit_code, int why, unsigned long message, if (gstop_done && (!current->ptrace || ptrace_reparented(current))) do_notify_parent_cldstop(current, false, why); + unlock_parents_siglocks(true); + + /* any trap clears pending STOP trap, STOP trap clears NOTIFY */ + task_clear_jobctl_pending(current, JOBCTL_TRAP_STOP); + if (info && info->si_code >> 8 == PTRACE_EVENT_STOP) + task_clear_jobctl_pending(current, JOBCTL_TRAP_NOTIFY); + + /* entering a trap, clear TRAPPING */ + task_clear_jobctl_trapping(current); + /* * Don't want to allow preemption here, because * sys_ptrace() needs this task to be inactive. * - * XXX: implement read_unlock_no_resched(). + * XXX: implement spin_unlock_no_resched(). */ preempt_disable(); - read_unlock(&tasklist_lock); + spin_unlock_irq(¤t->sighand->siglock); + cgroup_enter_frozen(); preempt_enable_no_resched(); freezable_schedule(); @@ -2361,8 +2490,8 @@ int ptrace_notify(int exit_code, unsigned long message) * on %true return. * * RETURNS: - * %false if group stop is already cancelled or ptrace trap is scheduled. - * %true if participated in group stop. + * %false if group stop is already cancelled. + * %true otherwise (as lock_parents_siglocks may have dropped siglock). */ static bool do_signal_stop(int signr) __releases(¤t->sighand->siglock) @@ -2425,36 +2554,24 @@ static bool do_signal_stop(int signr) } } + lock_parents_siglocks(false); + /* Recheck JOBCTL_STOP_PENDING after unlock+lock of siglock */ + if (unlikely(!(current->jobctl & JOBCTL_STOP_PENDING))) + goto out; if (likely(!current->ptrace)) { - int notify = 0; - /* * If there are no other threads in the group, or if there * is a group stop in progress and we are the last to stop, - * report to the parent. + * report to the real_parent. */ if (task_participate_group_stop(current)) - notify = CLD_STOPPED; + do_notify_parent_cldstop(current, false, CLD_STOPPED); + unlock_parents_siglocks(false); current->jobctl |= JOBCTL_STOPPED; set_special_state(TASK_STOPPED); spin_unlock_irq(¤t->sighand->siglock); - /* - * Notify the parent of the group stop completion. Because - * we're not holding either the siglock or tasklist_lock - * here, ptracer may attach inbetween; however, this is for - * group stop and should always be delivered to the real - * parent of the group leader. The new ptracer will get - * its notification when this task transitions into - * TASK_TRACED. - */ - if (notify) { - read_lock(&tasklist_lock); - do_notify_parent_cldstop(current, false, notify); - read_unlock(&tasklist_lock); - } - /* Now we don't run again until woken by SIGCONT or SIGKILL */ cgroup_enter_frozen(); freezable_schedule(); @@ -2465,8 +2582,11 @@ static bool do_signal_stop(int signr) * Schedule it and let the caller deal with it. */ task_set_jobctl_pending(current, JOBCTL_TRAP_STOP); - return false; } +out: + unlock_parents_siglocks(false); + spin_unlock_irq(¤t->sighand->siglock); + return true; } /** @@ -2624,32 +2744,30 @@ bool get_signal(struct ksignal *ksig) if (unlikely(signal->flags & SIGNAL_CLD_MASK)) { int why; - if (signal->flags & SIGNAL_CLD_CONTINUED) - why = CLD_CONTINUED; - else - why = CLD_STOPPED; + lock_parents_siglocks(true); + /* Recheck signal->flags after unlock+lock of siglock */ + if (likely(signal->flags & SIGNAL_CLD_MASK)) { + if (signal->flags & SIGNAL_CLD_CONTINUED) + why = CLD_CONTINUED; + else + why = CLD_STOPPED; - signal->flags &= ~SIGNAL_CLD_MASK; + signal->flags &= ~SIGNAL_CLD_MASK; - spin_unlock_irq(&sighand->siglock); - - /* - * Notify the parent that we're continuing. This event is - * always per-process and doesn't make whole lot of sense - * for ptracers, who shouldn't consume the state via - * wait(2) either, but, for backward compatibility, notify - * the ptracer of the group leader too unless it's gonna be - * a duplicate. - */ - read_lock(&tasklist_lock); - do_notify_parent_cldstop(current, false, why); - - if (ptrace_reparented(current->group_leader)) - do_notify_parent_cldstop(current->group_leader, - true, why); - read_unlock(&tasklist_lock); - - goto relock; + /* + * Notify the parent that we're continuing. This event is + * always per-process and doesn't make whole lot of sense + * for ptracers, who shouldn't consume the state via + * wait(2) either, but, for backward compatibility, notify + * the ptracer of the group leader too unless it's gonna be + * a duplicate. + */ + do_notify_parent_cldstop(current, false, why); + if (ptrace_reparented(current->group_leader)) + do_notify_parent_cldstop(current->group_leader, + true, why); + } + unlock_parents_siglocks(true); } for (;;) { @@ -2906,7 +3024,6 @@ static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which) void exit_signals(struct task_struct *tsk) { - int group_stop = 0; sigset_t unblocked; /* @@ -2937,21 +3054,20 @@ void exit_signals(struct task_struct *tsk) signotset(&unblocked); retarget_shared_pending(tsk, &unblocked); - if (unlikely(tsk->jobctl & JOBCTL_STOP_PENDING) && - task_participate_group_stop(tsk)) - group_stop = CLD_STOPPED; -out: - spin_unlock_irq(&tsk->sighand->siglock); - /* * If group stop has completed, deliver the notification. This * should always go to the real parent of the group leader. */ - if (unlikely(group_stop)) { - read_lock(&tasklist_lock); - do_notify_parent_cldstop(tsk, false, group_stop); - read_unlock(&tasklist_lock); + if (unlikely(tsk->jobctl & JOBCTL_STOP_PENDING)) { + lock_parents_siglocks(false); + /* Recheck JOBCTL_STOP_PENDING after unlock+lock of siglock */ + if ((tsk->jobctl & JOBCTL_STOP_PENDING) && + task_participate_group_stop(tsk)) + do_notify_parent_cldstop(tsk, false, CLD_STOPPED); + unlock_parents_siglocks(false); } +out: + spin_unlock_irq(&tsk->sighand->siglock); } /*