* [2.25 COMMITTED] hppa: Fix guard alignment in allocate_stack when stack grows up.
@ 2017-01-01 0:00 John David Anglin
0 siblings, 0 replies; only message in thread
From: John David Anglin @ 2017-01-01 0:00 UTC (permalink / raw)
To: Libc-stable Mailing List
[-- Attachment #1: Type: text/plain, Size: 112 bytes --]
Back port of commit 075385f98af239ff5807a5c6ed17fec51e048454.
Dave
--
John David Anglin dave.anglin@bell.net
[-- Attachment #2: allocatestack-v3-v2.25.d.txt --]
[-- Type: text/plain, Size: 1033 bytes --]
2017-08-12 John David Anglin <danglin@gcc.gnu.org>
* nptl/allocatestack.c (allocate_stack): Align old and new guard
addresses to page boundaries when the stack grows up.
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 8a228ab254..368fe3c36b 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -683,8 +683,14 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
prot) != 0)
goto mprot_error;
#elif _STACK_GROWS_UP
- if (mprotect ((char *) pd - pd->guardsize,
- pd->guardsize - guardsize, prot) != 0)
+ char *new_guard = (char *)(((uintptr_t) pd - guardsize)
+ & ~pagesize_m1);
+ char *old_guard = (char *)(((uintptr_t) pd - pd->guardsize)
+ & ~pagesize_m1);
+ /* The guard size difference might be > 0, but once rounded
+ to the nearest page the size difference might be zero. */
+ if (new_guard > old_guard
+ && mprotect (old_guard, new_guard - old_guard, prot) != 0)
goto mprot_error;
#endif
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-08-12 18:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-01 0:00 [2.25 COMMITTED] hppa: Fix guard alignment in allocate_stack when stack grows up John David Anglin
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).