]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
cheri: nptl: Check user provided stack for PCS constraints
authorCarlos Eduardo Seo <carlos.seo@arm.com>
Thu, 17 Mar 2022 23:51:32 +0000 (20:51 -0300)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 27 Oct 2022 13:46:55 +0000 (14:46 +0100)
In pthread_attr_setstack fail with EINVAL if the input stack does not
meet the PCS constraints.

nptl/pthread_attr_setstack.c

index e08b167df699b24b973130acea6b5f3a6729d817..a0338c27528576ece4885775d0908fa85e322f03 100644 (file)
@@ -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;