]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
aarch64: Fix missing BTI protection from dependencies [BZ #26926]
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 20 Nov 2020 15:27:06 +0000 (15:27 +0000)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 25 Nov 2020 15:03:28 +0000 (15:03 +0000)
The _dl_open_check and _rtld_main_check hooks are not called on the
dependencies of a loaded module, so BTI protection was missed on
every module other than the main executable and directly dlopened
libraries.

The fix just iterates over dependencies to enable BTI.

Fixes bug 26926.

sysdeps/aarch64/dl-bti.c

index 196e462520e0dc49bac57996eaaac5972635204e..8f4728adce87c7cbb96502e6552302fcd4e3f383 100644 (file)
@@ -51,11 +51,24 @@ enable_bti (struct link_map *map, const char *program)
   return 0;
 }
 
-/* Enable BTI for L if required.  */
+/* Enable BTI for MAP and its dependencies.  */
 
 void
-_dl_bti_check (struct link_map *l, const char *program)
+_dl_bti_check (struct link_map *map, const char *program)
 {
-  if (GLRO(dl_aarch64_cpu_features).bti && l->l_mach.bti)
-    enable_bti (l, program);
+  if (!GLRO(dl_aarch64_cpu_features).bti)
+    return;
+
+  if (map->l_mach.bti)
+    enable_bti (map, program);
+
+  unsigned int i = map->l_searchlist.r_nlist;
+  while (i-- > 0)
+    {
+      struct link_map *l = map->l_initfini[i];
+      if (l->l_init_called)
+       continue;
+      if (l->l_mach.bti)
+       enable_bti (l, program);
+    }
 }