]> sourceware.org Git - glibc.git/commitdiff
ARM: Don't apply pointer encryption to the frame pointer
authorWill Newton <will.newton@linaro.org>
Tue, 10 Dec 2013 16:26:38 +0000 (16:26 +0000)
committerWill Newton <will.newton@linaro.org>
Tue, 14 Jan 2014 14:02:34 +0000 (14:02 +0000)
The frame pointer register is rarely used for that purpose on ARM and
applications that look at the contents of the jmp_buf may be relying
on reading an unencrypted value. For example, Ruby uses the contents
of jmp_buf to find the root set for garbage collection so relies on
this pointer value being unencrypted. Without this patch the Ruby
testsuite fails with a segmentation fault.

ports/ChangeLog.arm:

2013-01-14  Will Newton  <will.newton@linaro.org>

* sysdeps/arm/__longjmp.S: Don't apply pointer encryption
to fp register.
* sysdeps/arm/setjmp.S: Likewise.
* sysdeps/arm/include/bits/setjmp.h (JMP_BUF_REGLIST): Add
fp to register list, remove a4.
* sysdeps/unix/sysv/linux/arm/sysdep.h (PTR_MANGLE_LOAD):
New macro.

ports/ChangeLog.arm
ports/sysdeps/arm/__longjmp.S
ports/sysdeps/arm/include/bits/setjmp.h
ports/sysdeps/arm/setjmp.S
ports/sysdeps/unix/sysv/linux/arm/sysdep.h

index 353c3d644421600547209e9ac07cbaba80995e56..4371b3ccfb57c60f9110f4867226fb2c1a658b91 100644 (file)
@@ -1,3 +1,13 @@
+2014-01-14  Will Newton  <will.newton@linaro.org>
+
+       * sysdeps/arm/__longjmp.S: Don't apply pointer encryption
+       to fp register.
+       * sysdeps/arm/setjmp.S: Likewise.
+       * sysdeps/arm/include/bits/setjmp.h (JMP_BUF_REGLIST): Add
+       fp to register list, remove a4.
+       * sysdeps/unix/sysv/linux/arm/sysdep.h (PTR_MANGLE_LOAD):
+       New macro.
+
 2014-01-10  Roland McGrath  <roland@hack.frob.com>
 
        * sysdeps/arm/arm-mcount.S:
index 1503923aaaae068d3787dcffdbab725b11ae6396..27c57a12df49686e9481de4852a98c5d6c5d00a7 100644 (file)
@@ -41,14 +41,12 @@ ENTRY (__longjmp)
        sfi_sp sfi_breg ip, \
        ldmia   \B!, JMP_BUF_REGLIST
 #ifdef PTR_DEMANGLE
-       PTR_DEMANGLE (fp, a4, a3, a2)
        ldr     a4, [ip], #4
-       PTR_DEMANGLE2 (a4, a4, a3)
+       PTR_DEMANGLE (a4, a4, a3, a2)
        mov     sp, a4
        ldr     a4, [ip], #4
        PTR_DEMANGLE2 (lr, a4, a3)
 #else
-       mov     fp, a4
        ldr     sp, [ip], #4
        ldr     lr, [ip], #4
 #endif
index 2f502457d81a1553c08b598c1a074de40a058a9c..220dfe8d9668c967596f89c791d42290df9de0ac 100644 (file)
@@ -26,9 +26,8 @@
 
 #ifndef _ISOMAC
 /* Register list for a ldm/stm instruction to load/store
-   the general registers from a __jmp_buf. The a4 register
-   contains fp at this point.  */
-# define JMP_BUF_REGLIST       {a4, v1-v6, sl}
+   the general registers from a __jmp_buf.  */
+# define JMP_BUF_REGLIST       {v1-v6, sl, fp}
 
 /* Index of __jmp_buf where the sp register resides.  */
 # define __JMP_BUF_SP          8
index 96657071dd1d8999f6aa5cbdd597333df09573fd..b0b45ed8da1e6f5215209fa4b2f971d947a0956e 100644 (file)
@@ -23,9 +23,7 @@
 
 ENTRY (__sigsetjmp)
 #ifdef PTR_MANGLE
-       PTR_MANGLE (a4, fp, a3, ip)
-#else
-       mov     a4, fp
+       PTR_MANGLE_LOAD (a3, ip)
 #endif
        mov     ip, r0
 
index 11d0a1146efb48e150b8a0d9d20edded66f723a6..dcd99198cc1b29a47f314ce038f5edf06d229fb8 100644 (file)
@@ -439,8 +439,10 @@ __local_syscall_error:                                             \
 #if (defined NOT_IN_libc && defined IS_IN_rtld) || \
   (!defined SHARED && (!defined NOT_IN_libc || defined IS_IN_libpthread))
 # ifdef __ASSEMBLER__
+#  define PTR_MANGLE_LOAD(guard, tmp)                                  \
+  LDST_PCREL(ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local));
 #  define PTR_MANGLE(dst, src, guard, tmp)                             \
-  LDST_PCREL(ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local)); \
+  PTR_MANGLE_LOAD(guard, tmp);                                         \
   PTR_MANGLE2(dst, src, guard)
 /* Use PTR_MANGLE2 for efficiency if guard is already loaded.  */
 #  define PTR_MANGLE2(dst, src, guard)         \
@@ -457,8 +459,10 @@ extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
 # endif
 #else
 # ifdef __ASSEMBLER__
+#  define PTR_MANGLE_LOAD(guard, tmp)                                  \
+  LDST_GLOBAL(ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard));
 #  define PTR_MANGLE(dst, src, guard, tmp)                             \
-  LDST_GLOBAL(ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard));    \
+  PTR_MANGLE_LOAD(guard, tmp);                                         \
   PTR_MANGLE2(dst, src, guard)
 /* Use PTR_MANGLE2 for efficiency if guard is already loaded.  */
 #  define PTR_MANGLE2(dst, src, guard)         \
This page took 0.050018 seconds and 5 git commands to generate.