public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/arm/morello/main] cheri: malloc: Ensure the mappings have RW permission
@ 2022-10-27 13:57 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-27 13:57 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=af11ceae3867a3786308738a6870a8f1016a865e

commit af11ceae3867a3786308738a6870a8f1016a865e
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Fri Oct 21 12:35:33 2022 +0100

    cheri: malloc: Ensure the mappings have RW permission
    
    The arena allocator incrementally applies RW mprotect to a PROT_NONE
    mapping.  Use PROT_MAX to ensure the pointers derived from the original
    mapping have RW capability permission.

Diff:
---
 malloc/malloc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 02df29d2ad..701adbebca 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1134,8 +1134,16 @@ static mchunkptr mremap_chunk(mchunkptr p, size_t new_size);
 # define MAP_NORESERVE 0
 #endif
 
+/* Allow RW mprotect later, on CHERI this means RW capability permission.  */
+#ifdef PROT_MAX
+# define PROT_MAX_RW PROT_MAX (PROT_READ | PROT_WRITE)
+#else
+# define PROT_MAX_RW 0
+#endif
+
 #define MMAP(addr, size, prot, flags) \
- __mmap((addr), (size), (prot), (flags)|MAP_ANONYMOUS|MAP_PRIVATE, -1, 0)
+ __mmap((addr), (size), (prot)|PROT_MAX_RW, \
+	(flags)|MAP_ANONYMOUS|MAP_PRIVATE, -1, 0)
 
 
 /*

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/arm/morello/main] cheri: malloc: Ensure the mappings have RW permission
@ 2022-11-23 14:46 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-11-23 14:46 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8b79bc92fab1cd4a8443cdcd3f9e313091d8bd62

commit 8b79bc92fab1cd4a8443cdcd3f9e313091d8bd62
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Fri Oct 21 12:35:33 2022 +0100

    cheri: malloc: Ensure the mappings have RW permission
    
    The arena allocator incrementally applies RW mprotect to a PROT_NONE
    mapping.  Use PROT_MAX to ensure the pointers derived from the original
    mapping have RW capability permission.

Diff:
---
 malloc/malloc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 02df29d2ad..701adbebca 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1134,8 +1134,16 @@ static mchunkptr mremap_chunk(mchunkptr p, size_t new_size);
 # define MAP_NORESERVE 0
 #endif
 
+/* Allow RW mprotect later, on CHERI this means RW capability permission.  */
+#ifdef PROT_MAX
+# define PROT_MAX_RW PROT_MAX (PROT_READ | PROT_WRITE)
+#else
+# define PROT_MAX_RW 0
+#endif
+
 #define MMAP(addr, size, prot, flags) \
- __mmap((addr), (size), (prot), (flags)|MAP_ANONYMOUS|MAP_PRIVATE, -1, 0)
+ __mmap((addr), (size), (prot)|PROT_MAX_RW, \
+	(flags)|MAP_ANONYMOUS|MAP_PRIVATE, -1, 0)
 
 
 /*

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/arm/morello/main] cheri: malloc: Ensure the mappings have RW permission
@ 2022-10-26 15:18 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 15:18 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c892e3eded6fa01b8adcfc837a1bdeb3efcea0c7

commit c892e3eded6fa01b8adcfc837a1bdeb3efcea0c7
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Fri Oct 21 12:35:33 2022 +0100

    cheri: malloc: Ensure the mappings have RW permission
    
    The arena allocator incrementally applies RW mprotect to a PROT_NONE
    mapping.  Use PROT_MAX to ensure the pointers derived from the original
    mapping have RW capability permission.

Diff:
---
 malloc/malloc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 02df29d2ad..701adbebca 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1134,8 +1134,16 @@ static mchunkptr mremap_chunk(mchunkptr p, size_t new_size);
 # define MAP_NORESERVE 0
 #endif
 
+/* Allow RW mprotect later, on CHERI this means RW capability permission.  */
+#ifdef PROT_MAX
+# define PROT_MAX_RW PROT_MAX (PROT_READ | PROT_WRITE)
+#else
+# define PROT_MAX_RW 0
+#endif
+
 #define MMAP(addr, size, prot, flags) \
- __mmap((addr), (size), (prot), (flags)|MAP_ANONYMOUS|MAP_PRIVATE, -1, 0)
+ __mmap((addr), (size), (prot)|PROT_MAX_RW, \
+	(flags)|MAP_ANONYMOUS|MAP_PRIVATE, -1, 0)
 
 
 /*

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/arm/morello/main] cheri: malloc: Ensure the mappings have RW permission
@ 2022-10-26 14:49 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 14:49 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=44283b4f2ff4dd8976209b6438e4279a0f3f07d5

commit 44283b4f2ff4dd8976209b6438e4279a0f3f07d5
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Fri Oct 21 12:35:33 2022 +0100

    cheri: malloc: Ensure the mappings have RW permission
    
    The arena allocator incrementally applies RW mprotect to a PROT_NONE
    mapping.  Use PROT_MAX to ensure the pointers derived from the original
    mapping have RW capability permission.

Diff:
---
 malloc/malloc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index cc222eaba2..392116a5ac 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1284,8 +1284,16 @@ static mchunkptr mremap_chunk(mchunkptr p, size_t new_size);
 # define MAP_NORESERVE 0
 #endif
 
+/* Allow RW mprotect later, on CHERI this means RW capability permission.  */
+#ifdef PROT_MAX
+# define PROT_MAX_RW PROT_MAX (PROT_READ | PROT_WRITE)
+#else
+# define PROT_MAX_RW 0
+#endif
+
 #define MMAP(addr, size, prot, flags) \
- __mmap((addr), (size), (prot), (flags)|MAP_ANONYMOUS|MAP_PRIVATE, -1, 0)
+ __mmap((addr), (size), (prot)|PROT_MAX_RW, \
+	(flags)|MAP_ANONYMOUS|MAP_PRIVATE, -1, 0)
 
 
 /*

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-23 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 13:57 [glibc/arm/morello/main] cheri: malloc: Ensure the mappings have RW permission Szabolcs Nagy
  -- strict thread matches above, loose matches on Subject: below --
2022-11-23 14:46 Szabolcs Nagy
2022-10-26 15:18 Szabolcs Nagy
2022-10-26 14:49 Szabolcs Nagy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).