summaryrefslogtreecommitdiff
path: root/nptl/pthread_getattr_np.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/pthread_getattr_np.c')
-rw-r--r--nptl/pthread_getattr_np.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c
index 75d717bb1f..7309185d14 100644
--- a/nptl/pthread_getattr_np.c
+++ b/nptl/pthread_getattr_np.c
@@ -120,8 +120,15 @@ pthread_getattr_np (thread_id, attr)
&& (uintptr_t) __libc_stack_end < to)
{
/* Found the entry. Now we have the info we need. */
- iattr->stacksize = rl.rlim_cur;
iattr->stackaddr = stack_end;
+ iattr->stacksize =
+ rl.rlim_cur - (size_t) (to - (uintptr_t) stack_end);
+
+ /* Cut it down to align it to page size since otherwise we
+ risk going beyond rlimit when the kernel rounds up the
+ stack extension request. */
+ iattr->stacksize = (iattr->stacksize
+ & -(intptr_t) GLRO(dl_pagesize));
/* The limit might be too high. */
if ((size_t) iattr->stacksize