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-08-05 19:45:19 +0100
commitcec148df6f86bd4cd6c2a4e95bca37840bc90d36 (patch)
tree34af2494de0eb87ad8a4bbc7a7e18896f7176ccf
parentd8173e2496e25ef68e409049eff1b672982af21c (diff)
downloadglibc-cec148df6f86bd4cd6c2a4e95bca37840bc90d36.tar.gz
glibc-cec148df6f86bd4cd6c2a4e95bca37840bc90d36.tar.xz
glibc-cec148df6f86bd4cd6c2a4e95bca37840bc90d36.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;