public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] nptl: Don't madvise user provided stack
@ 2020-06-25 13:20 Szabolcs Nagy
  0 siblings, 0 replies; only message in thread
From: Szabolcs Nagy @ 2020-06-25 13:20 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=087942251f26d5fd5802b8d14e47d460263a0c4d

commit 087942251f26d5fd5802b8d14e47d460263a0c4d
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Wed Jun 24 07:47:15 2020 +0100

    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

Diff:
---
 nptl/pthread_create.c | 5 +++--
 1 file 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))
     {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-25 13:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 13:20 [glibc] nptl: Don't madvise user provided stack Szabolcs Nagy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).