about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2022-10-06 12:00:39 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-10-27 14:46:55 +0100
commitf0f77b883f9e74e6843081af280aa291a9182601 (patch)
tree9a009dfbd93ab6dc787f38bc634bc0ede1613d98
parentb488de1ab2c613641c198f82c840b88a4d299fb4 (diff)
downloadglibc-f0f77b883f9e74e6843081af280aa291a9182601.tar.gz
glibc-f0f77b883f9e74e6843081af280aa291a9182601.tar.xz
glibc-f0f77b883f9e74e6843081af280aa291a9182601.zip
cheri: malloc: add tunable to turn narrowing off
-rw-r--r--elf/dl-tunables.list7
-rw-r--r--malloc/arena.c6
-rw-r--r--manual/tunables.texi6
3 files changed, 19 insertions, 0 deletions
diff --git a/elf/dl-tunables.list b/elf/dl-tunables.list
index e6a56b3070..83f47dcd9a 100644
--- a/elf/dl-tunables.list
+++ b/elf/dl-tunables.list
@@ -159,6 +159,13 @@ glibc {
       maxval: 255
       security_level: SXID_IGNORE
     }
+    cap_narrowing {
+      type: INT_32
+      minval: 0
+      maxval: 1
+      default: 1
+      security_level: SXID_IGNORE
+    }
   }
 
   rtld {
diff --git a/malloc/arena.c b/malloc/arena.c
index 894f49b911..85cc2ad066 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -326,6 +326,12 @@ ptmalloc_init (void)
   tcache_key_initialize ();
 #endif
 
+#ifdef __CHERI_PURE_CAPABILITY__
+  if (TUNABLE_GET_FULL (glibc, mem, cap_narrowing, int32_t, NULL) == 0)
+    cap_narrowing_enabled = false;
+  else
+    cap_narrowing_enabled = true;
+#endif
   cap_init ();
 
 #ifdef USE_MTAG
diff --git a/manual/tunables.texi b/manual/tunables.texi
index 83cdcdac6d..ffe0202627 100644
--- a/manual/tunables.texi
+++ b/manual/tunables.texi
@@ -612,3 +612,9 @@ support in the kernel if this tunable has any non-zero value.
 
 The default value is @samp{0}, which disables all memory tagging.
 @end deftp
+
+@deftp Tunable glibc.mem.cap_narrowing
+On CHERI architecture use capability bounds narrowing in the malloc
+implementation. By default it is set to 1, to disable bounds narrowing
+set it to 0.
+@end deftp