From 79e1550215fc7031e8f575e70e84cab7e34dea61 Mon Sep 17 00:00:00 2001
From: 4lDO2 <4lDO2@protonmail.com>
Date: Mon, 5 Aug 2024 16:09:36 +0200
Subject: [PATCH] Use only sig & 63 when checking SA_ONSTACK.

---
 redox-rt/src/arch/x86_64.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/redox-rt/src/arch/x86_64.rs b/redox-rt/src/arch/x86_64.rs
index 56cebb8f8..f1e5827ec 100644
--- a/redox-rt/src/arch/x86_64.rs
+++ b/redox-rt/src/arch/x86_64.rs
@@ -240,9 +240,12 @@ asmfunction!(__relibc_internal_sigentry: ["
     // skip the sigaltstack logic.
     lea rdx, [rip + {pctl} + {pctl_off_actions}]
 
+    mov ecx, eax
+    and ecx, 63
+
     // LEA doesn't support 16x, so just do two x8s.
-    lea rdx, [rdx + 8 * rax]
-    lea rdx, [rdx + 8 * rax]
+    lea rdx, [rdx + 8 * rcx]
+    lea rdx, [rdx + 8 * rcx]
 
     bt qword ptr [rdx], {SA_ONSTACK_BIT}
     jnc 4f
-- 
GitLab