Kernel: Push missing IP and SP to mcontext in signal handler
I was missing these two registers, messing up the whole siginfo_t structure. This fixes libc's stack trace dump crashing :D
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
.section .userspace, "ax"
|
.section .userspace, "ax"
|
||||||
|
|
||||||
// stack contains
|
// stack contains
|
||||||
// (4 bytes) return address
|
// (4 bytes) return address (on return stack)
|
||||||
// (4 bytes) return stack
|
// (4 bytes) return stack
|
||||||
// (4 bytes) return rflags
|
// (4 bytes) return rflags
|
||||||
// (8 bytes) restore sigmask
|
// (8 bytes) restore sigmask
|
||||||
@@ -19,6 +19,10 @@ signal_trampoline:
|
|||||||
pushl %eax
|
pushl %eax
|
||||||
pushl %ebp
|
pushl %ebp
|
||||||
|
|
||||||
|
movl 80(%esp), %eax
|
||||||
|
pushl %eax; addl $4, (%esp)
|
||||||
|
pushl (%eax)
|
||||||
|
|
||||||
// FIXME: populate these
|
// FIXME: populate these
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
pushl %eax // stack
|
pushl %eax // stack
|
||||||
@@ -29,9 +33,9 @@ signal_trampoline:
|
|||||||
pushl %eax // link
|
pushl %eax // link
|
||||||
|
|
||||||
movl %esp, %edx // ucontext
|
movl %esp, %edx // ucontext
|
||||||
leal 60(%esp), %esi // siginfo
|
leal 68(%esp), %esi // siginfo
|
||||||
movl 56(%esp), %edi // signal number
|
movl 64(%esp), %edi // signal number
|
||||||
movl 52(%esp), %eax // handlers
|
movl 60(%esp), %eax // handlers
|
||||||
|
|
||||||
// align stack to 16 bytes
|
// align stack to 16 bytes
|
||||||
movl %esp, %ebp
|
movl %esp, %ebp
|
||||||
@@ -62,6 +66,7 @@ signal_trampoline:
|
|||||||
int $0xF0
|
int $0xF0
|
||||||
|
|
||||||
// restore registers
|
// restore registers
|
||||||
|
addl $8, %esp
|
||||||
popl %ebp
|
popl %ebp
|
||||||
popl %eax
|
popl %eax
|
||||||
popl %ebx
|
popl %ebx
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.section .userspace, "ax"
|
.section .userspace, "ax"
|
||||||
|
|
||||||
// stack contains
|
// stack contains
|
||||||
// (8 bytes) return address
|
// (8 bytes) return address (on return stack)
|
||||||
// (8 bytes) return stack
|
// (8 bytes) return stack
|
||||||
// (8 bytes) return rflags
|
// (8 bytes) return rflags
|
||||||
// (8 bytes) restore sigmask
|
// (8 bytes) restore sigmask
|
||||||
@@ -27,6 +27,10 @@ signal_trampoline:
|
|||||||
pushq %rax
|
pushq %rax
|
||||||
pushq %rbp
|
pushq %rbp
|
||||||
|
|
||||||
|
movq 208(%rsp), %rax
|
||||||
|
pushq %rax; addq $(128 + 8), (%rsp)
|
||||||
|
pushq (%rax)
|
||||||
|
|
||||||
// FIXME: populate these
|
// FIXME: populate these
|
||||||
xorq %rax, %rax
|
xorq %rax, %rax
|
||||||
pushq %rax // stack
|
pushq %rax // stack
|
||||||
@@ -36,9 +40,9 @@ signal_trampoline:
|
|||||||
pushq %rax // link
|
pushq %rax // link
|
||||||
|
|
||||||
movq %rsp, %rdx // ucontext
|
movq %rsp, %rdx // ucontext
|
||||||
leaq 176(%rsp), %rsi // siginfo
|
leaq 192(%rsp), %rsi // siginfo
|
||||||
movq 168(%rsp), %rdi // signal number
|
movq 184(%rsp), %rdi // signal number
|
||||||
movq 160(%rsp), %rax // handler
|
movq 176(%rsp), %rax // handler
|
||||||
|
|
||||||
// align stack to 16 bytes
|
// align stack to 16 bytes
|
||||||
movq %rsp, %rbp
|
movq %rsp, %rbp
|
||||||
@@ -64,6 +68,7 @@ signal_trampoline:
|
|||||||
syscall
|
syscall
|
||||||
|
|
||||||
// restore registers
|
// restore registers
|
||||||
|
addq $16, %rsp
|
||||||
popq %rbp
|
popq %rbp
|
||||||
popq %rax
|
popq %rax
|
||||||
popq %rbx
|
popq %rbx
|
||||||
|
|||||||
Reference in New Issue
Block a user