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 DCDB4C433FE for ; Tue, 10 May 2022 14:05:01 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=rrlld3ITPvxgzmN4tVBPU1fpU5s9kt9zsiNYZd0gqsw=; b=Xo7jW56SML2VlW UJcd2mbJMHT2lczzQZPUMlG4LZb8n0hfGC0lXmK65cnVHru67QR5O6C9Cu+XSD7UpuvfPHYbFs4SU xIKxcFO0at8d++kypKgPCl+k9aqc49ubRnKouafrNAWErEJ6cgCGW4Blfop1ajbf+X3j+2mDXyfxj X3VT0/kTkIseA/Zza1gix35DCJaQd7bCpQyrPz9CLZ+vORhJTwbKKdQK7noprZ5XOeaO/psAqCSjH TelRq6qQhKjyi3BlekC+jDe9psyERFz6FD2W6TSkZ6LSWZjzINvjRgC1dTHgD8HfRlfkH9xuFcxao ZRtm29DnaRr3IsoP4poA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1noQSl-002OPq-KB; Tue, 10 May 2022 14:03:43 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1noQSi-002OOu-N9 for linux-arm-kernel@lists.infradead.org; Tue, 10 May 2022 14:03:42 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1C46560A21; Tue, 10 May 2022 14:03:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B0D7C385C2; Tue, 10 May 2022 14:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652191419; bh=KjDXrMRIgjl9mqK+1lZepnUpO/sXpVuQ6BE0MJGcLl4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ftzgu9vNda3LniGP6pt1aUYcmfQNMsGRCzzkPe7Ju5jVv55Vo8Km6RS6REDd052BK ZPSzQRrNz/z5Du+mxpMlcqlPRTPsmXopKmmYWzaDphQboUeez0V7FKSP1JjN23tjlb YbJIEKiZUVtLttBvGAarW3b+yiJOB2QP7KW1vJBiLvnWPZAb6OYhQqogyC9ukkZgj4 JkP8meYhGRCkL0uFRsxf0b5UAMx61qj+hYK3iSmMDh4I6KugoCSWl0zalm+qzFmdLE f0pb8YOFwvDDTqVNFf219lp7UUQPvIwvUm5Y3ccEBaBLTXfjz6Lc80JiSmYd/GrMkM zVa5iw1mP7J7g== Date: Tue, 10 May 2022 15:03:33 +0100 From: Will Deacon To: Francis Laniel 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*() Message-ID: <20220510140333.GA28104@willie-the-truck> References: <20220509151958.441240-1-flaniel@linux.microsoft.com> <20220509151958.441240-2-flaniel@linux.microsoft.com> <20220510105948.GB27557@willie-the-truck> <2826417.e9J7NaK4W3@pwmachine> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2826417.e9J7NaK4W3@pwmachine> 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-20220510_070340_869841_A48F54EF X-CRM114-Status: GOOD ( 21.31 ) 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 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..e12ceb363d6a > > > 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, unsigned > > > 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 ca= se > > either. > > = > > How do other architectures handle this? > = > My understanding of others architectures is quite limited, but here are m= y = > findings and understanding of some of them: > * arm (32 bits) EABI: start_thread() sets r7 to previous r7 for ELF FDPIC= 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 which= 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 con= tain = > 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? Catalin? It's been there since day one afaict. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel