[packages/redis] Rel 3. Use x86_64 mcontext layout on x32, crash handler read wrong registers and crashed again.

arekm arekm at pld-linux.org
Thu Oct 15 09:27:48 CEST 2026


commit 3a282fddff162a19182276a33f8a0ea45d19b9a8
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Thu Oct 15 09:26:48 2026 +0200

    Rel 3. Use x86_64 mcontext layout on x32, crash handler read wrong registers and crashed again.

 redis-x32-mcontext.patch | 41 +++++++++++++++++++++++++++++++++++++++++
 redis.spec               |  4 +++-
 2 files changed, 44 insertions(+), 1 deletion(-)
---
diff --git a/redis.spec b/redis.spec
index 8beedd2..fe85f8e 100644
--- a/redis.spec
+++ b/redis.spec
@@ -9,7 +9,7 @@
 Summary:	A persistent key-value database
 Name:		redis
 Version:	8.10.2
-Release:	2
+Release:	3
 License:	AGPLv3
 Group:		Applications/Databases
 Source0:	https://download.redis.io/releases/%{name}-%{version}.tar.gz
@@ -23,6 +23,7 @@ Patch0:		%{name}.conf.patch
 Patch1:		%{name}-tcl.patch
 Patch2:		0001-1st-man-pageis-for-redis-cli-redis-benchmark-redis-c.patch
 Patch3:		system-jemalloc.patch
+Patch4:		%{name}-x32-mcontext.patch
 URL:		https://www.redis.io/
 %{?with_system_jemalloc:BuildRequires:	jemalloc-devel}
 %ifarch %{arm}
@@ -78,6 +79,7 @@ disk.
 %patch -P0 -p1
 %patch -P1 -p1
 %patch -P2 -p1
+%patch -P4 -p1
 %if %{with system_jemalloc}
 %patch -P3 -p1
 
diff --git a/redis-x32-mcontext.patch b/redis-x32-mcontext.patch
new file mode 100644
index 0000000..8e7a2d4
--- /dev/null
+++ b/redis-x32-mcontext.patch
@@ -0,0 +1,41 @@
+x32 has the 64-bit x86_64 mcontext layout; using i386 register indices there makes the
+crash handler read RCX as EIP and R15 as the stack pointer and crash again while reporting
+
+--- redis-8.10.2.orig/src/debug.c	2026-10-15 09:05:28.932800927 +0200
++++ redis-8.10.2/src/debug.c	2026-10-15 09:05:55.672229062 +0200
+@@ -1426,7 +1426,7 @@
+     return NULL;\
+ } while(0)
+ #define GET_SET_RETURN(target_var, new_val) do {\
+-    void *old_val = (void*)target_var; \
++    void *old_val = (void*)(uintptr_t)target_var; \
+     if (new_val) { \
+         void **temp = (void**)&target_var; \
+         *temp = new_val; \
+@@ -1458,7 +1458,7 @@
+     #endif
+ #elif defined(__linux__)
+     /* Linux */
+-    #if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
++    #if defined(__i386__)
+     GET_SET_RETURN(uc->uc_mcontext.gregs[14], eip);
+     #elif defined(__X86_64__) || defined(__x86_64__)
+     GET_SET_RETURN(uc->uc_mcontext.gregs[16], eip);
+@@ -1652,7 +1652,7 @@
+ /* Linux */
+ #elif defined(__linux__)
+     /* Linux x86 */
+-    #if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
++    #if defined(__i386__)
+     serverLog(LL_WARNING,
+     "\n"
+     "EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n"
+@@ -1706,7 +1706,7 @@
+         (unsigned long) uc->uc_mcontext.gregs[17],
+         (unsigned long) uc->uc_mcontext.gregs[18]
+     );
+-    logStackContent((void**)uc->uc_mcontext.gregs[15]);
++    logStackContent((void**)(uintptr_t)uc->uc_mcontext.gregs[15]);
+     #elif defined(__riscv) /* Linux RISC-V */
+     serverLog(LL_WARNING,
+ 	"\n"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/redis.git/commitdiff/3a282fddff162a19182276a33f8a0ea45d19b9a8



More information about the pld-cvs-commit mailing list