From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87355C433E0 for ; Wed, 27 May 2020 12:16:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 457CF20657 for ; Wed, 27 May 2020 12:16:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rJZ/7xBZ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZF2owS80" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 457CF20657 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=imrqqgX1+aLORl2ejQT2pfxpRGVvU9lnsVSFHfgdQQ4=; b=rJZ/7xBZPlm8ud LMtUeDljw+86ikuJSdHDNI8AEtTF2CznDQmFx0TdamW2vRCJtj951fMJFEtRv7AmmvBDFZ8/XAjPi ElEZ2woWSjzgw4BYk6e0XfO+/Mcrnne+v6laRJBmZZAOZR/yb3LVnYnoRsvkIp6ZKKOatH0jEbQHt n6yfoV37ThQdT9SL7VsTNPpITdqwK7XSaQOb1+z3bS9cNEIigz2kmbdW4InLRUDggipiWIthxAA3D F/sJ039xrRXku13rzpgqPy2/ASBLu/dGwCqDj1pEJLfdSoluTCFHl9Kc7GZntBDSxs7SJmReBpnnJ CEYSZFbcnJQlg2Op24OA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jduzA-0003NN-Bh; Wed, 27 May 2020 12:16:40 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jdupt-000712-Cg for linux-arm-kernel@lists.infradead.org; Wed, 27 May 2020 12:07:07 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2D17D20657; Wed, 27 May 2020 12:07:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590581224; bh=RgGyDDKi+fu1bR4P7/Fy0rAi8l/nj+5VQFHBDoSVtcE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZF2owS806SpqYaXKfAjq4KlQVTMhd3lE42KLHUkrkI0jk2s9E+iagY48+Hm3Oo+XT nvHs6GpcbizIFvPC4o+ZkCNj53a1eZRaXG4EY+2IjXtnUvSW2sd0fJtOcUKJr+xUh/ EgFThQ6CjGzY8Kx0Us2CTc7S5XtDXf4gsvvXIWqw= Date: Wed, 27 May 2020 13:06:59 +0100 From: Will Deacon To: Keno Fischer Subject: Re: [PATCH] arm64: ptrace: Fix PTRACE_SINGLESTEP into signal handler Message-ID: <20200527120659.GC13795@willie-the-truck> References: <20200524043827.GA33001@juliacomputing.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200524043827.GA33001@juliacomputing.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200527_050705_483061_F185DEA1 X-CRM114-Status: GOOD ( 22.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: catalin.marinas@arm.com, oleg@redhat.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, May 24, 2020 at 12:38:27AM -0400, Keno Fischer wrote: > Executing PTRACE_SINGLESTEP at a signal stop is special. It > is supposed to step merely the signal setup work that the > kernel does, but not any instructions in user space. Since > not all architectures have the ability to generate a > single-step exception directly upon return from user-space, > there is a generic pseudo-single-step-stop that may be used > for this purpose (tracehook_signal_handler). Now, arm64 does > have the ability to generate single-step exceptions directly > upon return to userspace and was using this capability (rather > than the generic pseudo-trap) to obtain a similar effect. However, > there is actually a subtle difference that becomes noticeable > when the signal handler in question attempts to block SIGTRAP > (either because it is set in sa_mask, or because it is a handler > for SIGTRAP itself and SA_NODEFER is not set). In such a > situation, a real single step exception will cause the SIGTRAP > signal to be forcibly unblocked and the signal disposition > to be reset to SIG_DFL. The generic pseudo-single-step does > not suffer from this problem, because the SIGTRAP it delivers > is not real. The arm64 behavior is problematic, because a forced > reset of the signal disposition can be quite disruptive to the > userspace program. This patch brings the arm64 behavior in line > with the other major architectures by using the generic > pseudo-single-step-stop, avoiding the problematic interaction > with SIGTRAP masks. > > Fixes: 2c020ed8 ("arm64: Signal handling support") nit: please use a 12-character ID here. > Signed-off-by: Keno Fischer > --- > arch/arm64/kernel/signal.c | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c > index 339882db5a91..cf237ee9443b 100644 > --- a/arch/arm64/kernel/signal.c > +++ b/arch/arm64/kernel/signal.c > @@ -808,14 +808,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) > */ > ret |= !valid_user_regs(®s->user_regs, current); > > - /* > - * Fast forward the stepping logic so we step into the signal > - * handler. > - */ > - if (!ret) > - user_fastforward_single_step(tsk); > - > - signal_setup_done(ret, ksig, 0); > + signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); another nit: tsk is now unused, so this generates a compiler warning: arch/arm64/kernel/signal.c:787:22: warning: unused variable 'tsk' [-Wunused-variable] struct task_struct *tsk = current; ^ 1 warning generated. Also, the si_code used by signal_setup_done seems to be SIGTRAP, whereas we usually set TRAP_TRACE. What's the correct behaviour here? Looks like x86 uses TRAP_BRKPT... :/ Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel