aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/aarch64/dl-prop.h
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2020-12-01 10:13:18 +0000
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2020-12-11 15:46:02 +0000
commitcd543b5eb3642d76e365a131ce676f31fe3f1dd4 (patch)
tree1e9d3fae1efab8985fe543032bb9949650ea98c4 /sysdeps/aarch64/dl-prop.h
parentc00452d7757a300931ee186d043c43b48eeb0875 (diff)
downloadglibc-cd543b5eb3642d76e365a131ce676f31fe3f1dd4.zip
glibc-cd543b5eb3642d76e365a131ce676f31fe3f1dd4.tar.gz
glibc-cd543b5eb3642d76e365a131ce676f31fe3f1dd4.tar.bz2
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>
Diffstat (limited to 'sysdeps/aarch64/dl-prop.h')
-rw-r--r--sysdeps/aarch64/dl-prop.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/sysdeps/aarch64/dl-prop.h b/sysdeps/aarch64/dl-prop.h
index 2016d14..e926e54 100644
--- a/sysdeps/aarch64/dl-prop.h
+++ b/sysdeps/aarch64/dl-prop.h
@@ -19,6 +19,8 @@
#ifndef _DL_PROP_H
#define _DL_PROP_H
+extern void _dl_bti_protect (struct link_map *, int) attribute_hidden;
+
extern void _dl_bti_check (struct link_map *, const char *)
attribute_hidden;
@@ -43,6 +45,10 @@ static inline int
_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
uint32_t datasz, void *data)
{
+ if (!GLRO(dl_aarch64_cpu_features).bti)
+ /* Skip note processing. */
+ return 0;
+
if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND)
{
/* Stop if the property note is ill-formed. */
@@ -51,7 +57,7 @@ _dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
unsigned int feature_1 = *(unsigned int *) data;
if (feature_1 & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
- l->l_mach.bti = true;
+ _dl_bti_protect (l, fd);
/* Stop if we processed the property note. */
return 0;