From: Carlos Eduardo Seo Date: Thu, 17 Mar 2022 23:51:32 +0000 (-0300) Subject: cheri: nptl: Check user provided stack for PCS constraints X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6827cd8b558a4fa191ad285bde4a17efdd758db;p=thirdparty%2Fglibc.git 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. --- diff --git a/nptl/pthread_attr_setstack.c b/nptl/pthread_attr_setstack.c index e08b167df69..a0338c27528 100644 --- a/nptl/pthread_attr_setstack.c +++ b/nptl/pthread_attr_setstack.c @@ -19,7 +19,9 @@ #include #include "pthreadP.h" #include - +#ifdef __CHERI_PURE_CAPABILITY__ +# include +#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;