From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Brown Subject: Re: [PATCH v10 00/13] arm64: Branch Target Identification support Date: Mon, 23 Mar 2020 13:24:12 +0000 Message-ID: <20200323132412.GD4948@sirena.org.uk> References: <20200316165055.31179-1-broonie@kernel.org> <20200320173945.GC27072@arm.com> <20200323122143.GB4892@mbp> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="n2Pv11Ogg/Ox8ay5" Return-path: Received: from foss.arm.com ([217.140.110.172]:48924 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728344AbgCWNYP (ORCPT ); Mon, 23 Mar 2020 09:24:15 -0400 Content-Disposition: inline In-Reply-To: <20200323122143.GB4892@mbp> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Catalin Marinas Cc: 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 --n2Pv11Ogg/Ox8ay5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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; > +} > At a quick look, for dynamic binaries we have has_interp == true and > is_interp == false. I don't know why but, either way, the above code > needs a comment with some justification. I don't really know for certain either, I inherited this code as is with the understanding that this was all agreed with the toolchain and libc people - the actual discussion that lead to the decisions being made happened before I was involved. My understanding is that the idea was that the dynamic linker would be responsible for mapping everything in dynamic applications other than itself but other than consistency I don't know why. I guess it defers more decision making to userspace but I'm having a hard time thinking of sensible cases where one might wish to make a decision other than enabling PROT_BTI. I'd be perfectly happy to drop the check if that makes more sense to people, otherwise I can send a patch adding a comment explaining the situation. --n2Pv11Ogg/Ox8ay5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl54uHwACgkQJNaLcl1U h9DAYQf+PC+yaMtvYW9mN4nKAz7ncHVrReSbAGM8vzqPWdFAlq9YUOWrM19ZtwX3 Reos273yUIeierbiwvJMNq+eDPFo9bF3mqTxkQr5uA4+RDAqXedTNeS637lX1tG3 /uzSb0uqwvff1A9+IZsavz2GuhK8WNmybN7xbOPD1SLHZd4ouEiMlBoE3Ze+nMqm gClUEz9TTAmK6m9sL7rchJgnSFoG5OU4F/6sWpCoip4mFa5QnBAkeWh6RssDImFg hIm9njv6a9aeNHTw1YnM1heqRe86GkmGk3LsgGrHETzDNFOwlBNek95tXIVl7W7I f99IlRUisKUN9wu9VYAtNzRSGiDGLQ== =70MP -----END PGP SIGNATURE----- --n2Pv11Ogg/Ox8ay5-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com ([217.140.110.172]:48924 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728344AbgCWNYP (ORCPT ); Mon, 23 Mar 2020 09:24:15 -0400 Date: Mon, 23 Mar 2020 13:24:12 +0000 From: Mark Brown Subject: Re: [PATCH v10 00/13] arm64: Branch Target Identification support Message-ID: <20200323132412.GD4948@sirena.org.uk> References: <20200316165055.31179-1-broonie@kernel.org> <20200320173945.GC27072@arm.com> <20200323122143.GB4892@mbp> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="n2Pv11Ogg/Ox8ay5" Content-Disposition: inline In-Reply-To: <20200323122143.GB4892@mbp> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Catalin Marinas Cc: 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: <20200323132412.bLYxPquHk2DNDQSf3uCZ548CxlDoiUECQMV-wfuGdYg@z> --n2Pv11Ogg/Ox8ay5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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; > +} > At a quick look, for dynamic binaries we have has_interp == true and > is_interp == false. I don't know why but, either way, the above code > needs a comment with some justification. I don't really know for certain either, I inherited this code as is with the understanding that this was all agreed with the toolchain and libc people - the actual discussion that lead to the decisions being made happened before I was involved. My understanding is that the idea was that the dynamic linker would be responsible for mapping everything in dynamic applications other than itself but other than consistency I don't know why. I guess it defers more decision making to userspace but I'm having a hard time thinking of sensible cases where one might wish to make a decision other than enabling PROT_BTI. I'd be perfectly happy to drop the check if that makes more sense to people, otherwise I can send a patch adding a comment explaining the situation. --n2Pv11Ogg/Ox8ay5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl54uHwACgkQJNaLcl1U h9DAYQf+PC+yaMtvYW9mN4nKAz7ncHVrReSbAGM8vzqPWdFAlq9YUOWrM19ZtwX3 Reos273yUIeierbiwvJMNq+eDPFo9bF3mqTxkQr5uA4+RDAqXedTNeS637lX1tG3 /uzSb0uqwvff1A9+IZsavz2GuhK8WNmybN7xbOPD1SLHZd4ouEiMlBoE3Ze+nMqm gClUEz9TTAmK6m9sL7rchJgnSFoG5OU4F/6sWpCoip4mFa5QnBAkeWh6RssDImFg hIm9njv6a9aeNHTw1YnM1heqRe86GkmGk3LsgGrHETzDNFOwlBNek95tXIVl7W7I f99IlRUisKUN9wu9VYAtNzRSGiDGLQ== =70MP -----END PGP SIGNATURE----- --n2Pv11Ogg/Ox8ay5--