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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D078BC433EF for ; Tue, 10 May 2022 14:13:12 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject: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=IAUI8vkqvxmbhlqJ3Tkn+RujAQ9D6t+5D37whBp7euk=; b=KizApq/fYa+4+5 szXR/kxsxYVk1zWLhmu55gbw6R05I3yTCZbuVZxRQpGkpVQIHRfvvFQC4J9a0B6MgBRxhlgwOTUmm MpHSK1mZotglKG/P7+rSshdQwC+q+wDiCGgjQq82S9JP7L3zMwfRSYCgjOG+KjnXXVZmAlm/Rdvae /GEz6YA9Jn1x9NcGurPFHiy9O1gwWZ+qAGlMtHabKimxS79FDBC0DbW1cSafPWF+DPY9yeEez1ccL HYfauPoUyi4hniqi/hpZ43KICwUl00lBrGyQc2u6XSGp4K+gUertRgf8Gw7Gi2NUyeLNWwLMxcXgE BOa8eFgLebfn9eJFlj+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1noQb0-002SBA-0w; Tue, 10 May 2022 14:12:14 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1noQaw-002S9I-5k for linux-arm-kernel@lists.infradead.org; Tue, 10 May 2022 14:12:11 +0000 Received: from pwmachine.localnet (154.pool92-186-13.dynamic.orange.es [92.186.13.154]) by linux.microsoft.com (Postfix) with ESMTPSA id 98D7C20DED47; Tue, 10 May 2022 07:12:05 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 98D7C20DED47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1652191929; bh=SMXRjgASxoY9GANcr+RrOLPmCsV3l+6OdEbY8o5d4Y0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P/umbaWjpofQ6mQCCPA8N0L2yqe2CopqIn/eA+AtE38GGYUb5NNJGPC3It4bPFOHP ri2QItOL4uMuhiPwcHtz2dNHE2g2+C7ePm/PvHMlOnhTB8vOQBUBTG0fFHKSXx6V5g ZUA1qzPjqM1HMWfqk3fUJVY03fO965VV9fWaSUmQ= From: Francis Laniel To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-trace-devel@vger.kernel.org, Catalin Marinas , Mark Brown , Peter Collingbourne , Mark Rutland , Kees Cook , Daniel Kiss , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v1 1/1] arm64: Forget syscall if different from execve*() Date: Tue, 10 May 2022 15:12:02 +0100 Message-ID: <8061631.T7Z3S40VBb@pwmachine> Organization: Microsoft In-Reply-To: <20220510140333.GA28104@willie-the-truck> References: <20220509151958.441240-1-flaniel@linux.microsoft.com> <2826417.e9J7NaK4W3@pwmachine> <20220510140333.GA28104@willie-the-truck> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220510_071210_300246_3759CB94 X-CRM114-Status: GOOD ( 23.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Le mardi 10 mai 2022, 15:03:33 BST Will Deacon a =E9crit : > On Tue, May 10, 2022 at 03:00:11PM +0100, Francis Laniel wrote: > > Le mardi 10 mai 2022, 11:59:48 BST Will Deacon a =E9crit : > > > On Mon, May 09, 2022 at 04:19:57PM +0100, Francis Laniel wrote: > > > > diff --git a/arch/arm64/include/asm/processor.h > > > > b/arch/arm64/include/asm/processor.h index 73e38d9a540c..e12ceb363d= 6a > > > > 100644 > > > > --- a/arch/arm64/include/asm/processor.h > > > > +++ b/arch/arm64/include/asm/processor.h > > > > @@ -34,6 +34,8 @@ > > > > = > > > > #include > > > > = > > > > +#include > > > > + > > > > = > > > > #include > > > > #include > > > > #include > > > > = > > > > @@ -250,8 +252,12 @@ void tls_preserve_current_state(void); > > > > = > > > > static inline void start_thread_common(struct pt_regs *regs, unsig= ned > > > > long pc) { > > > > = > > > > + s32 previous_syscall =3D regs->syscallno; > > > > = > > > > memset(regs, 0, sizeof(*regs)); > > > > = > > > > - forget_syscall(regs); > > > > + if (previous_syscall =3D=3D __NR_execve || previous_syscall =3D= =3D > > > > __NR_execveat) > > > > + regs->syscallno =3D previous_syscall; > > > > + else > > > > + forget_syscall(regs); > > > = > > > Hmm, this really looks like a bodge and it doesn't handle the compat > > > case > > > either. > > > = > > > How do other architectures handle this? > > = > > My understanding of others architectures is quite limited, but here are= my > > findings and understanding of some of them: > > * arm (32 bits) EABI: start_thread() sets r7 to previous r7 for ELF FDP= IC = > > and to 0 for other binfmts [1]. > > * arm (32 bits) OABI: syscall number is set to -1 if > > ptrace_report_syscall_entry() failed [2]. > > * mips: start_thread() does not modify current_thread_info->syscall whi= ch > > is taken directly from v0 [3, 4]. > > * riscv: start_thread() does not modify a7 [5]. > > * x86_64: start_thread_common() does not touch orig_ax which seems to > > contain the syscall number [6]. > = > Hmm, so the million dollar question is why on Earth we have that > forget_syscall() call to start with. Amusingly I've, err, forgotten; > forget_forget_syscall() perhaps? I think this is maybe tied to this comment [1]: The de-facto standard way to skip a system call using ptrace = is to set the system call to -1 (NO_SYSCALL) But I will let the original author explain as his/her explaination will be = better than mine. > Catalin? It's been there since day one afaict. > = > Will --- [1] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/arm64/kernel/ syscall.c#L121 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel