[PATCH 04/12] nptl/allocatestack.c: Fix stack mprotect alignment for STACK_GROWS_UP

Markos Chandras markos.chandras at gmail.com
Thu Feb 21 10:12:01 UTC 2013


From: Markos Chandras <markos.chandras at imgtec.com>

mprotect() expects the first argument to be aligned to a page boundary.

Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
 libpthread/nptl/allocatestack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c
index 9399c2a..3f0586d 100644
--- a/libpthread/nptl/allocatestack.c
+++ b/libpthread/nptl/allocatestack.c
@@ -645,7 +645,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 			prot) != 0)
 	    goto mprot_error;
 #elif defined _STACK_GROWS_UP
-	  if (mprotect ((char *) pd - pd->guardsize,
+	  if (mprotect ((char *) (((uintptr_t) pd - pd->guardsize) & ~pagesize_m1),
 			pd->guardsize - guardsize, prot) != 0)
 	    goto mprot_error;
 #endif
-- 
1.8.1.2




More information about the uClibc mailing list