From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id D2DDB3858009; Fri, 5 Aug 2022 19:37:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2DDB3858009 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] cheri: nptl: Check user provided stack for PCS constraints X-Act-Checkin: glibc X-Git-Author: Carlos Eduardo Seo X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: d8173e2496e25ef68e409049eff1b672982af21c X-Git-Newrev: cec148df6f86bd4cd6c2a4e95bca37840bc90d36 Message-Id: <20220805193726.D2DDB3858009@sourceware.org> Date: Fri, 5 Aug 2022 19:37:26 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2022 19:37:26 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cec148df6f86bd4cd6c2a4e95bca37840bc90d36 commit cec148df6f86bd4cd6c2a4e95bca37840bc90d36 Author: Carlos Eduardo Seo Date: Thu Mar 17 20:51:32 2022 -0300 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: --- nptl/pthread_attr_setstack.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 #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;