From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Rutland Subject: Re: [PATCH v10 00/13] arm64: Branch Target Identification support Date: Mon, 23 Mar 2020 15:02:09 +0000 Message-ID: <20200323150209.GC3959@C02TD0UTHF1T.local> References: <20200316165055.31179-1-broonie@kernel.org> <20200320173945.GC27072@arm.com> <20200323122143.GB4892@mbp> <20200323132412.GD4948@sirena.org.uk> <20200323135722.GA3959@C02TD0UTHF1T.local> <20200323143954.GC4892@mbp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from foss.arm.com ([217.140.110.172]:50762 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbgCWPCQ (ORCPT ); Mon, 23 Mar 2020 11:02:16 -0400 Content-Disposition: inline In-Reply-To: <20200323143954.GC4892@mbp> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Catalin Marinas Cc: Mark Brown , Szabolcs Nagy , Will Deacon , Alexander Viro , Paul Elliott , Peter Zijlstra , Yu-cheng Yu , Amit Kachhap , Vincenzo Frascino , Marc Zyngier , Eugene Syromiatnikov , "H . J . Lu " , Andrew Jones , Kees Cook , Arnd Bergmann , Jann Horn , Richard Henderson , Kristina =?utf-8?Q?Mart=C5=A1enko?= , Thomas Gleixner Florian Weimer On Mon, Mar 23, 2020 at 02:39:55PM +0000, Catalin Marinas wrote: > On Mon, Mar 23, 2020 at 01:57:22PM +0000, Mark Rutland wrote: > > On Mon, Mar 23, 2020 at 01:24:12PM +0000, Mark Brown wrote: > > > On Mon, Mar 23, 2020 at 12:21:44PM +0000, Catalin Marinas wrote: > > > > On Fri, Mar 20, 2020 at 05:39:46PM +0000, Szabolcs Nagy wrote: > > > > > > > +int arch_elf_adjust_prot(int prot, const struct arch_elf_state *state, > > > > + bool has_interp, bool is_interp) > > > > +{ > > > > + if (is_interp != has_interp) > > > > + return prot; > > > > + > > > > + if (!(state->flags & ARM64_ELF_BTI)) > > > > + return prot; > > > > + > > > > + if (prot & PROT_EXEC) > > > > + prot |= PROT_BTI; > > > > + > > > > + return prot; > > > > +} > > I think it would be best to document the current behaviour, as it's a > > simple ABI that we can guarantee, and the dynamic linker will have to be > > aware of BTI in order to do the right thing anyhow. > > That's a valid point. If we have an old dynamic linker and the kernel > enabled BTI automatically for the main executable, could things go wrong > (e.g. does the PLT need to be BTI-aware)? Also worth noting that an old dynamic linker won't have ARM64_ELF_BTI set, so the kernel will not enable BTI for this. Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com ([217.140.110.172]:50762 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbgCWPCQ (ORCPT ); Mon, 23 Mar 2020 11:02:16 -0400 Date: Mon, 23 Mar 2020 15:02:09 +0000 From: Mark Rutland Subject: Re: [PATCH v10 00/13] arm64: Branch Target Identification support Message-ID: <20200323150209.GC3959@C02TD0UTHF1T.local> References: <20200316165055.31179-1-broonie@kernel.org> <20200320173945.GC27072@arm.com> <20200323122143.GB4892@mbp> <20200323132412.GD4948@sirena.org.uk> <20200323135722.GA3959@C02TD0UTHF1T.local> <20200323143954.GC4892@mbp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200323143954.GC4892@mbp> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Catalin Marinas Cc: Mark Brown , Szabolcs Nagy , Will Deacon , Alexander Viro , Paul Elliott , Peter Zijlstra , Yu-cheng Yu , Amit Kachhap , Vincenzo Frascino , Marc Zyngier , Eugene Syromiatnikov , "H . J . Lu " , Andrew Jones , Kees Cook , Arnd Bergmann , Jann Horn , Richard Henderson , Kristina =?utf-8?Q?Mart=C5=A1enko?= , Thomas Gleixner , Florian Weimer , Sudakshina Das , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, nd@arm.com Message-ID: <20200323150209.StxvDlp7bOGM4Ie3zh-ZZufWwn8_F-W2pDnNadtCr8g@z> On Mon, Mar 23, 2020 at 02:39:55PM +0000, Catalin Marinas wrote: > On Mon, Mar 23, 2020 at 01:57:22PM +0000, Mark Rutland wrote: > > On Mon, Mar 23, 2020 at 01:24:12PM +0000, Mark Brown wrote: > > > On Mon, Mar 23, 2020 at 12:21:44PM +0000, Catalin Marinas wrote: > > > > On Fri, Mar 20, 2020 at 05:39:46PM +0000, Szabolcs Nagy wrote: > > > > > > > +int arch_elf_adjust_prot(int prot, const struct arch_elf_state *state, > > > > + bool has_interp, bool is_interp) > > > > +{ > > > > + if (is_interp != has_interp) > > > > + return prot; > > > > + > > > > + if (!(state->flags & ARM64_ELF_BTI)) > > > > + return prot; > > > > + > > > > + if (prot & PROT_EXEC) > > > > + prot |= PROT_BTI; > > > > + > > > > + return prot; > > > > +} > > I think it would be best to document the current behaviour, as it's a > > simple ABI that we can guarantee, and the dynamic linker will have to be > > aware of BTI in order to do the right thing anyhow. > > That's a valid point. If we have an old dynamic linker and the kernel > enabled BTI automatically for the main executable, could things go wrong > (e.g. does the PLT need to be BTI-aware)? Also worth noting that an old dynamic linker won't have ARM64_ELF_BTI set, so the kernel will not enable BTI for this. Mark.