Commit 8f74187a authored by Alexander Kartashov's avatar Alexander Kartashov Committed by Pavel Emelyanov

arm: don't use the register R12 in the routine syscall_common()

The register R12 has a special meaning when syscalls are hooked
with ptrace() in ARM that results in a dumpee context corruption
on an injected blob unmap. Note that this patch doesn't solve
the problem entirely since the compiler may corrupt the register
before issuing a call to the routine sys_munmap(); however
we assume that a sufficiently decent compiler doesn't.
Signed-off-by: 's avatarAlexander Kartashov <alekskartashov@parallels.com>
Tested-by: 's avatarAndrew Vagin <avagin@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 4e2031ca
#include "asm/linkage.h" #include "asm/linkage.h"
@ We use the register R8 unlike libc that uses R12.
@ This avoids corruption of the register by the stub
@ for the syscall sys_munmap() when syscalls are hooked
@ by ptrace(). However we have to make sure that
@ the compiler doesn't use the register on the route
@ between parasite_service() and sys_munmap().
syscall_common: syscall_common:
ldr %r7, [%r7] ldr %r7, [%r7]
add %ip, %sp, #16 add %r8, %sp, #24
ldm %ip, {%r4, %r5, %r6} ldm %r8, {%r4, %r5, %r6}
svc 0x00000000 svc 0x00000000
pop {%r4, %r5, %r6, %r7} pop {%r4, %r5, %r6, %r7, %r8, %pc}
bx %lr
.macro syscall name, nr .macro syscall name, nr
...@@ -14,7 +20,7 @@ syscall_common: ...@@ -14,7 +20,7 @@ syscall_common:
.long \nr .long \nr
ENTRY(\name) ENTRY(\name)
push {%r4, %r5, %r6, %r7} push {%r4, %r5, %r6, %r7, %r8, %lr}
adr %r7, .nr_\name adr %r7, .nr_\name
b syscall_common b syscall_common
END(\name) END(\name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment