summaryrefslogtreecommitdiff
path: root/nptl-Don-t-madvise-user-provided-stack.patch
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2024-10-15 06:24:53 +0000
committerCoprDistGit <infra@openeuler.org>2024-10-15 06:24:53 +0000
commit2fb6e0cf79df2056e9750e29669c4633555e74b8 (patch)
treea1ad5fd201e579ad1245110c036501053a8794b3 /nptl-Don-t-madvise-user-provided-stack.patch
parent711949a2ac2288db2115787d9d9cca9cef093ccf (diff)
automatic import of glibcopeneuler22.03_LTS_SP3
Diffstat (limited to 'nptl-Don-t-madvise-user-provided-stack.patch')
-rw-r--r--nptl-Don-t-madvise-user-provided-stack.patch41
1 files changed, 41 insertions, 0 deletions
diff --git a/nptl-Don-t-madvise-user-provided-stack.patch b/nptl-Don-t-madvise-user-provided-stack.patch
new file mode 100644
index 0000000..41937de
--- /dev/null
+++ b/nptl-Don-t-madvise-user-provided-stack.patch
@@ -0,0 +1,41 @@
+From 087942251f26d5fd5802b8d14e47d460263a0c4d Mon Sep 17 00:00:00 2001
+From: Szabolcs Nagy <szabolcs.nagy@arm.com>
+Date: Wed, 24 Jun 2020 07:47:15 +0100
+Subject: [PATCH] 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
+
+---
+ 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 179f07a1..00931c19 100644
+--- a/nptl/pthread_create.c
++++ b/nptl/pthread_create.c
+@@ -564,8 +564,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))
+ {
+--
+2.19.1
+