From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id DB163385E001; Wed, 23 Nov 2022 14:46:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB163385E001 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669214773; bh=nI6DHh3f18UXoZDchRoEqjHQKJV8NaipfW7OlggCv2Y=; h=From:To:Subject:Date:From; b=qtovVhcvA/IX3C011+ZsNF984NZq2u+rChS3jZstJBG7pL+Ags2slX829d+XEGhz4 WsjdQHqz0LqGcm/+gqFh6gCGPjWVCocWccS05JmXYJX7oMPsDda9TO6sVJGcTzU2g3 GX5Ts3vnxivcLVadLc3BgTSiGRYKtDhQPcqy34ok= 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: Fix capability permissions of PROT_NONE map in locarchive X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: cb78f7d9d3cfd05d71208d199dafdb28ea05a92c X-Git-Newrev: 8e860da0db41471ac5a4c68b4838308c13ba5f41 Message-Id: <20221123144613.DB163385E001@sourceware.org> Date: Wed, 23 Nov 2022 14:46:13 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8e860da0db41471ac5a4c68b4838308c13ba5f41 commit 8e860da0db41471ac5a4c68b4838308c13ba5f41 Author: Szabolcs Nagy Date: Tue Oct 25 11:20:48 2022 +0100 cheri: Fix capability permissions of PROT_NONE map in locarchive Diff: --- locale/programs/locarchive.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c index eeb2fa6ffe..81a980b60b 100644 --- a/locale/programs/locarchive.c +++ b/locale/programs/locarchive.c @@ -84,6 +84,13 @@ static const char *locnames[] = /* Size of the reserved address space area. */ #define RESERVE_MMAP_SIZE 512 * 1024 * 1024 +/* 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 + /* To prepare for enlargements of the mmaped area reserve some address space. On some machines, being a file mapping rather than an anonymous mapping affects the address selection. So do this mapping from the @@ -94,7 +101,8 @@ prepare_address_space (int fd, size_t total, size_t *reserved, int *xflags, { if (total < RESERVE_MMAP_SIZE) { - void *p = mmap64 (NULL, RESERVE_MMAP_SIZE, PROT_NONE, MAP_SHARED, fd, 0); + void *p = mmap64 (NULL, RESERVE_MMAP_SIZE, + PROT_NONE | PROT_MAX_RW, MAP_SHARED, fd, 0); if (p != MAP_FAILED) { void *aligned_p = PTR_ALIGN_UP (p, MAP_FIXED_ALIGNMENT);