public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/arm/morello/main] cheri: nptl: Fix thread stack capability permissions
@ 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=cb78f7d9d3cfd05d71208d199dafdb28ea05a92c

commit cb78f7d9d3cfd05d71208d199dafdb28ea05a92c
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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))

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

* [glibc/arm/morello/main] cheri: nptl: Fix thread stack capability permissions
@ 2022-10-27 13:56 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-27 13:56 UTC (permalink / raw)
  To: glibc-cvs

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

commit c31913cc4121f13e1ef283bb8f82c1a9f21358f0
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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))

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

* [glibc/arm/morello/main] cheri: nptl: Fix thread stack capability permissions
@ 2022-10-26 15:17 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 15:17 UTC (permalink / raw)
  To: glibc-cvs

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

commit 3d59fb52744155021dc50b70d48470cd2810d593
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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))

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

* [glibc/arm/morello/main] cheri: nptl: Fix thread stack capability permissions
@ 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=b2854b0bcc5ffeeeadd3209c46d89eca78ce43a3

commit b2854b0bcc5ffeeeadd3209c46d89eca78ce43a3
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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))

^ 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-11-23 14:46 [glibc/arm/morello/main] cheri: nptl: Fix thread stack capability permissions Szabolcs Nagy
  -- strict thread matches above, loose matches on Subject: below --
2022-10-27 13:56 Szabolcs Nagy
2022-10-26 15:17 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).