about summary refs log tree commit diff
path: root/nptl/pthread_create.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2020-06-24 07:47:15 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2020-06-25 14:19:16 +0100
commit087942251f26d5fd5802b8d14e47d460263a0c4d (patch)
tree58df96511a0b52696ba666628506ba37f913abac /nptl/pthread_create.c
parentf6b955e8ba4f0bcc7b9dafa64406d3b40edfa107 (diff)
downloadglibc-087942251f26d5fd5802b8d14e47d460263a0c4d.tar.gz
glibc-087942251f26d5fd5802b8d14e47d460263a0c4d.tar.xz
glibc-087942251f26d5fd5802b8d14e47d460263a0c4d.zip
nptl: Don't madvise user provided stack
User provided stack should not be released nor madvised at
thread exit because it's owned by the user.

If the memory is shared or file based then MADV_DONTNEED
can have unwanted effects. With memory tagging on aarch64
linux the tags are dropped and thus it may invalidate
pointers.

Tested on aarch64-linux-gnu with MTE, it fixes

FAIL: nptl/tst-stack3
FAIL: nptl/tst-stack3-mem
Diffstat (limited to 'nptl/pthread_create.c')
-rw-r--r--nptl/pthread_create.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 35a9927cf2..6d6ab88960 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -549,8 +549,9 @@ START_THREAD_DEFN
     }
 #endif
 
-  advise_stack_range (pd->stackblock, pd->stackblock_size, (uintptr_t) pd,
-		      pd->guardsize);
+  if (!pd->user_stack)
+    advise_stack_range (pd->stackblock, pd->stackblock_size, (uintptr_t) pd,
+			pd->guardsize);
 
   if (__glibc_unlikely (pd->cancelhandling & SETXID_BITMASK))
     {