diff options
author | John David Anglin <danglin@gcc.gnu.org> | 2017-07-15 12:40:13 -0400 |
---|---|---|
committer | John David Anglin <danglin@gcc.gnu.org> | 2017-07-15 12:40:13 -0400 |
commit | 075385f98af239ff5807a5c6ed17fec51e048454 (patch) | |
tree | 4daa5d6e521d62b372bc7e69bc9036d0b61b4b0f | |
parent | 2759a2c1d8b950521ae76e62efe0114fd36b6e2d (diff) | |
download | glibc-075385f98af239ff5807a5c6ed17fec51e048454.zip glibc-075385f98af239ff5807a5c6ed17fec51e048454.tar.gz glibc-075385f98af239ff5807a5c6ed17fec51e048454.tar.bz2 |
Fix guard alignment in allocate_stack when stack grows up.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | nptl/allocatestack.c | 10 |
2 files changed, 11 insertions, 2 deletions
@@ -1,5 +1,8 @@ 2017-07-15 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. + * sysdeps/hppa/math-tests.h: New. 2017-07-14 DJ Delorie <dj@redhat.com> diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index ec7d42e..ce2e24a 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -697,8 +697,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 |