about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCarlos Eduardo Seo <carlos.seo@arm.com>2022-03-17 20:51:32 -0300
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-10-27 14:46:55 +0100
commitc6827cd8b558a4fa191ad285bde4a17efdd758db (patch)
tree21a081df1e3be7bfb8629b63651230b9327d4621
parent82187c0633092f7b4f55ec93ab651dec84fe1413 (diff)
downloadglibc-c6827cd8b558a4fa191ad285bde4a17efdd758db.tar.gz
glibc-c6827cd8b558a4fa191ad285bde4a17efdd758db.tar.xz
glibc-c6827cd8b558a4fa191ad285bde4a17efdd758db.zip
cheri: nptl: Check user provided stack for PCS constraints
In pthread_attr_setstack fail with EINVAL if the input stack does not
meet the PCS constraints.
-rw-r--r--nptl/pthread_attr_setstack.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/nptl/pthread_attr_setstack.c b/nptl/pthread_attr_setstack.c
index e08b167df6..a0338c2752 100644
--- a/nptl/pthread_attr_setstack.c
+++ b/nptl/pthread_attr_setstack.c
@@ -19,7 +19,9 @@
 #include <limits.h>
 #include "pthreadP.h"
 #include <shlib-compat.h>
-
+#ifdef __CHERI_PURE_CAPABILITY__
+# include <cheri_perms.h>
+#endif
 
 #ifndef NEW_VERNUM
 # define NEW_VERNUM GLIBC_2_3_3
@@ -43,6 +45,11 @@ __pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr,
   EXTRA_PARAM_CHECKS;
 #endif
 
+#ifdef __CHERI_PURE_CAPABILITY__
+  if (!STACK_CAP_CHECK (stackaddr, stacksize))
+    return EINVAL;
+#endif
+
   iattr->stacksize = stacksize;
 #if _STACK_GROWS_DOWN
   iattr->stackaddr = (char *) stackaddr + stacksize;