diff options
author | Carlos Eduardo Seo <carlos.seo@arm.com> | 2022-03-17 20:51:32 -0300 |
---|---|---|
committer | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2022-11-22 14:31:25 +0000 |
commit | 5e606fb79cbf9b701f50d0dde041d19ce0b423eb (patch) | |
tree | 30ace160fc0240467fe88776774fdb92b60cf4e7 | |
parent | 040bc860fe46e7f7c1e99de92565398656b6b5e9 (diff) | |
download | glibc-5e606fb79cbf9b701f50d0dde041d19ce0b423eb.tar.gz |
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.c | 9 |
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; |