From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id F4141385E45D; Wed, 26 Oct 2022 14:49:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F4141385E45D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666795765; bh=0q2tpM5dDcmaTn8qc+GrhqZPcPvX9juaX9nVvOOY6zI=; h=From:To:Subject:Date:From; b=v81iStSOObohv/7MFopf7E4emUNgj/4fcGWnXayzlTHMl5RjZDTur69UABZlcRdjo TJeNvO8GLoQS8mPg+/TSDr5w3B0qyMZCy6tMYtxIGwJ/j0iYLlBIBQw5WFYLaJI2tn 822HJTfHMRRAx+XtNNlJN4wT40Wazg9H8ZEMldmQ= 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: Fix thread stack capability permissions X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: 40b60cc1dbed3ab3f742177374300f3ba87eb550 X-Git-Newrev: b2854b0bcc5ffeeeadd3209c46d89eca78ce43a3 Message-Id: <20221026144924.F4141385E45D@sourceware.org> Date: Wed, 26 Oct 2022 14:49:18 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b2854b0bcc5ffeeeadd3209c46d89eca78ce43a3 commit b2854b0bcc5ffeeeadd3209c46d89eca78ce43a3 Author: Szabolcs Nagy Date: Mon Oct 24 16:18:42 2022 +0100 cheri: nptl: Fix thread stack capability permissions Diff: --- nptl/allocatestack.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 219854f2cb..755ace5ec4 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -52,6 +52,13 @@ # define MAP_STACK 0 #endif +/* On CHERI targets ensure the mmap returned capability has RW permissions. */ +#ifdef PROT_MAX +# define PROT_MAX_RW PROT_MAX (PROT_READ | PROT_WRITE) +#else +# define PROT_MAX_RW 0 +#endif + /* Get a stack frame from the cache. We have to match by size since some blocks might be too small or far too large. */ static struct pthread * @@ -363,7 +370,8 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, /* If a guard page is required, avoid committing memory by first allocate with PROT_NONE and then reserve with required permission excluding the guard page. */ - mem = __mmap (NULL, size, (guardsize == 0) ? prot : PROT_NONE, + mem = __mmap (NULL, size, + (guardsize == 0) ? prot : PROT_NONE | PROT_MAX_RW, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0); if (__glibc_unlikely (mem == MAP_FAILED))