Kernel: Make i386 thread tramplines crash

This commit is contained in:
Bananymous 2024-03-26 00:07:24 +02:00
parent 26585bb1d9
commit 2dd0bfdece
2 changed files with 7 additions and 34 deletions

View File

@ -4,44 +4,17 @@ read_ip:
popl %eax popl %eax
jmp *%eax jmp *%eax
exit_thread_trampoline:
addl $4, %esp
pushl (%esp)
ret
# void start_thread(uint32_t sp, uint32_t ip) # void start_thread(uint32_t sp, uint32_t ip)
.global start_thread .global start_thread
start_thread: start_thread:
movl 8(%esp), %ecx ud2
movl 4(%esp), %esp
movl $0, %ebp
pushl $exit_thread_trampoline
sti
jmp *%ecx
# void continue_thread(uint32_t sp, uint32_t ip) # void continue_thread(uint32_t sp, uint32_t ip)
.global continue_thread .global continue_thread
continue_thread: continue_thread:
movl 8(%esp), %ecx ud2
movl 4(%esp), %esp
movl $0, %eax
jmp *%ecx
# void thread_jump_userspace(uint32_t sp, uint32_t ip) # void thread_userspace_trampoline(uint32_t sp, uint32_t ip, int argc, char** argv, char** envp)
.global thread_jump_userspace .global thread_userspace_trampoline
thread_jump_userspace: thread_userspace_trampoline:
movl $0x23, %eax ud2
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
movl 8(%esp), %ecx
movl 4(%esp), %esp
pushl $0x23
pushl %esp
pushfl
pushl $0x1B
pushl %ecx
iret

View File

@ -1,4 +1,4 @@
# uint64_t read_() # uint64_t read_ip()
.global read_ip .global read_ip
read_ip: read_ip:
popq %rax popq %rax