summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2015-05-06 18:37:19 -0400
committerRich Felker <dalias@aerifal.cx>2015-05-06 18:37:19 -0400
commit484194dbf41758eec0ef62fef5fe9350c21b9241 (patch)
treed0b407880ba1c62f9fd3b551c6e9a9e745bd8cdd /arch
parentd0040e239e8d3048a7fb38f0bacaad4838fac605 (diff)
downloadmusl-484194dbf41758eec0ef62fef5fe9350c21b9241.tar.gz
fix stack protector crashes on x32 & powerpc due to misplaced TLS canary
i386, x86_64, x32, and powerpc all use TLS for stack protector canary values in the default stack protector ABI, but the location only matched the ABI on i386 and x86_64. on x32, the expected location for the canary contained the tid, thus producing spurious mismatches (resulting in process termination) upon fork. on powerpc, the expected location contained the stdio_locks list head, so returning from a function after calling flockfile produced spurious mismatches. in both cases, the random canary was not present, and a predictable value was used instead, making the stack protector hardening much less effective than it should be. in the current fix, the thread structure has been expanded to have canary fields at all three possible locations, and archs that use a non-default location must define a macro in pthread_arch.h to choose which location is used. for most archs (which lack TLS canary ABI) the choice does not matter.
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/pthread_arch.h1
-rw-r--r--arch/x32/pthread_arch.h2
2 files changed, 3 insertions, 0 deletions
diff --git a/arch/powerpc/pthread_arch.h b/arch/powerpc/pthread_arch.h
index 2d1ee43c..4115ec8c 100644
--- a/arch/powerpc/pthread_arch.h
+++ b/arch/powerpc/pthread_arch.h
@@ -17,3 +17,4 @@ static inline struct pthread *__pthread_self()
// GPRs.
#define CANCEL_REG_IP 32
+#define CANARY canary_at_end
diff --git a/arch/x32/pthread_arch.h b/arch/x32/pthread_arch.h
index 23e10516..033bfd69 100644
--- a/arch/x32/pthread_arch.h
+++ b/arch/x32/pthread_arch.h
@@ -8,3 +8,5 @@ static inline struct pthread *__pthread_self()
#define TP_ADJ(p) (p)
#define CANCEL_REG_IP 32
+
+#define CANARY canary2