[PATCH v8 2/4] arm64: Enable BTI for main executable as well as the interpreter

Catalin Marinas catalin.marinas at arm.com
Fri Feb 4 05:11:52 PST 2022


On Mon, Jan 24, 2022 at 03:07:02PM +0000, Mark Brown wrote:
> Currently for dynamically linked ELF executables we only enable BTI for
> the interpreter, expecting the interpreter to do this for the main
> executable. This is a bit inconsistent since we do map main executable and
> is causing issues with systemd's MemoryDenyWriteExecute feature which is
> implemented using a seccomp filter which prevents setting PROT_EXEC on
> already mapped memory and lacks the context to be able to detect that
> memory is already mapped with PROT_EXEC.
> 
> Resolve this by checking the BTI property for the main executable and
> enabling BTI if it is present when doing the initial mapping. This does
> mean that we may get more code with BTI enabled if running on a system
> without BTI support in the dynamic linker, this is expected to be a safe
> configuration and testing seems to confirm that.

Alternatively we could only enable BTI on the main executable if the
interpreter is also compiled with the BTI attributes. But it still feels
a bit inconsistent as a BTI-capable interpreter doesn't necessarily mean
it had to be compiled with BTI support.

> It also reduces the
> flexibility userspace has to disable BTI but it is expected that for cases
> where there are problems which require BTI to be disabled it is more likely
> that it will need to be disabled on a system level.

That's my expectation as well. I'm not aware of any plans to make a
dynamic loader choose BTI based on some environment variable (not sure
about Android zygote, I haven't heard anything either).

> Signed-off-by: Mark Brown <broonie at kernel.org>
> Reviewed-by: Dave Martin <Dave.Martin at arm.com>
> Tested-by: Jeremy Linton <jeremy.linton at arm.com>

For this patch:

Reviewed-by: Catalin Marinas <catalin.marinas at arm.com>



More information about the linux-arm-kernel mailing list