Re: [PATCH v10 00/13] arm64: Branch Target Identification support
From: Mark Brown <broonie@kernel.org>
Date: 2020-03-23 13:24:18
Also in:
linux-arch, linux-fsdevel, lkml
From: Mark Brown <broonie@kernel.org>
Date: 2020-03-23 13:24:18
Also in:
linux-arch, linux-fsdevel, lkml
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.