]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Don't madvise user provided stack
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 24 Jun 2020 06:47:15 +0000 (07:47 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 25 Jun 2020 13:19:16 +0000 (14:19 +0100)
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

nptl/pthread_create.c

index 35a9927cf25c1f6a3f90d295fd30dc482abd4a75..6d6ab88960e64bac37daf8711bc987fc69befd38 100644 (file)
@@ -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))
     {