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-11-22 14:31:25 +0000
commit5e606fb79cbf9b701f50d0dde041d19ce0b423eb (patch)
tree30ace160fc0240467fe88776774fdb92b60cf4e7
parent040bc860fe46e7f7c1e99de92565398656b6b5e9 (diff)
downloadglibc-5e606fb79cbf9b701f50d0dde041d19ce0b423eb.tar.gz
glibc-5e606fb79cbf9b701f50d0dde041d19ce0b423eb.tar.xz
glibc-5e606fb79cbf9b701f50d0dde041d19ce0b423eb.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;