]> git.ipfire.org Git - thirdparty/glibc.git/commit
aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831]
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Tue, 1 Dec 2020 10:13:18 +0000 (10:13 +0000)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 11 Dec 2020 15:46:02 +0000 (15:46 +0000)
commitcd543b5eb3642d76e365a131ce676f31fe3f1dd4
tree1e9d3fae1efab8985fe543032bb9949650ea98c4
parentc00452d7757a300931ee186d043c43b48eeb0875
aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831]

Re-mmap executable segments if possible instead of using mprotect
to add PROT_BTI. This allows using BTI protection with security
policies that prevent mprotect with PROT_EXEC.

If the fd of the ELF module is not available because it was kernel
mapped then mprotect is used and failures are ignored.  To protect
the main executable even when mprotect is filtered the linux kernel
 will have to be changed to add PROT_BTI to it.

The delayed failure reporting is mainly needed because currently
_dl_process_gnu_properties does not propagate failures such that
the required cleanups happen. Using the link_map_machine struct for
error propagation is not ideal, but this seemed to be the least
intrusive solution.

Fixes bug 26831.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
sysdeps/aarch64/dl-bti.c
sysdeps/aarch64/dl-prop.h
sysdeps/aarch64/linkmap.h