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=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 D293BC433E0 for ; Sun, 31 May 2020 09:33:33 +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 9A88520707 for ; Sun, 31 May 2020 09:33:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MP+guGiA"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="QVgLaPjK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A88520707 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=dpGD1BSChZL34cAyXNj3cd48ULLM/VZn4l644+0HaiA=; b=MP+guGiAf81RbB 5YI3UXBHmv75/iln2kba3dD4SASGo2n2mkvmgm4cGlTVapy8HxypJz49wS5RYAK7HDHnFma/0ZBA8 7I48YN+FYsFsJjAWty6IShv4/33oYuvf+vZWTmTTPfqG4n28W0WIx33j2Xzbkc2fNYHJJkLdMnDyF Umz3eHOBTmDzkS5CR2uovbaC33VMOyBzUJdV7TLSQSCm9Dxi5YEmQd0yoxr70i5bt1gDvR3GHeArV OXMMLl6D7RkpDlMkp0rU4aVzoWFYLkmnuL7jTzBXbIT06fz2vikOAMoowS9rJ7yby0DU8nDRmBoLt kfumXooWX4Sb89pHnAvQ==; 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 1jfKLU-0004Uu-6J; Sun, 31 May 2020 09:33:32 +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 1jfKLQ-0004Tv-4v for linux-arm-kernel@lists.infradead.org; Sun, 31 May 2020 09:33:29 +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 C00F620707; Sun, 31 May 2020 09:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590917606; bh=kbhIhCTvdYW4T4mcknrnXd2owAVuTRk+XLhdT0D6n/g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QVgLaPjKeNPKoDEZ3JzbTnF18GnJA5ji6Z7/k7XbKT9vyhxZX0am6CiqSmG5G8xZI 7zfxuddxUHbu/04/SOXjg60iwuTMZ7iRTiNMsfUUDqhvDbx+undYop7J56Az0Pg51r VZkcNB7+Mx+HVp74Zo3tw7nyo3RS3y9l7eaESOFY= Date: Sun, 31 May 2020 10:33:21 +0100 From: Will Deacon To: Dave Martin Subject: Re: arm64: Register modification during syscall entry/exit stop Message-ID: <20200531093320.GA30204@willie-the-truck> References: <20200519081551.GA9980@willie-the-truck> <20200520174149.GB27629@willie-the-truck> <20200527095528.GC11111@willie-the-truck> <20200527101929.GT5031@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200527101929.GT5031@arm.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-20200531_023328_238194_A06F45C0 X-CRM114-Status: GOOD ( 22.73 ) 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: Kyle Huey , Catalin Marinas , Linux Kernel Mailing List , Oleg Nesterov , Keno Fischer , linux-arm-kernel@lists.infradead.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 Wed, May 27, 2020 at 11:19:29AM +0100, Dave Martin wrote: > On Wed, May 27, 2020 at 10:55:29AM +0100, Will Deacon wrote: > > On Sun, May 24, 2020 at 02:56:35AM -0400, Keno Fischer wrote: > > > Just ran into this issue again, with what I think may be most compelling > > > example yet why this is problematic: > > > > > > The tracee incurred a signal, we PTRACE_SYSEMU'd to the rt_sigreturn, > > > which the tracer tried to emulate by applying the state from the signal frame. > > > However, the PTRACE_SYSEMU stop is a syscall-stop, so the tracer's write > > > to x7 was ignored and x7 retained the value it had in the signal handler, > > > which broke the tracee. > > > > Yeah, that sounds like a good justification to add a way to stop this. Could > > you send a patch, please? > > > > Interestingly, I *thought* the current behaviour was needed by strace, but I > > can't find anything there that seems to require it. Oh well, we're stuck > > with it anyway. > > The fact that PTRACE_SYSEMU is only implemented for a few arches makes > we wonder whether it was a misguided addition that should not be ported > to new arches... i.e., why does hardly anyone need it? But I haven't > attempted to understand the history. > > Can't PTRACE_SYSEMU be emulated by using PTRACE_SYSCALL, cancelling the > syscall at the syscall enter stop, then modifying the regs at the > syscall exit stop? > > > If SYSEMU was obviously always broken, perhaps we can withdraw support > for it. Assuming nobody is crazy enough to try to emulate execve() I > can't see anything other than sigreturn that would be affected by this > issue though. So maybe SYSEMU isn't broken enough to justify > withdrawal. Indeed, my preference on another thread [1] was to remove it, but it would need agreement from Arm, since it was added by them (Sudeep). But setting that aside, Keno has convinced me that the clobbering of x7 on syscall enter/exit can cause some problems for userspace, so I think that having a way to disable that seems like a good idea. We can't change the current default behaviour, but having an explicit opt-in seems worthwhile. Keno -- are you planning to send out a patch? You previously spoke about implementing this using PTRACE_SETOPTIONS. Will [1] https://lore.kernel.org/r/20200515121346.GA22919@willie-the-truck _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel