mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-27 03:41:23 +08:00
Fix guard alignment in allocate_stack when stack grows up.
* nptl/allocatestack.c (allocate_stack): Align old and new guard addresses to page boundaries when the stack grows up.
This commit is contained in:
parent
f40b4e86f5
commit
d215bbdff3
@ -1,5 +1,8 @@
|
||||
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.
|
||||
|
||||
* sysdeps/hppa/math-tests.h: New.
|
||||
|
||||
[BZ #21016]
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user