From 2dd0bfdece34254a938cab8e410b26b3c201a5ea Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 26 Mar 2024 00:07:24 +0200 Subject: [PATCH] Kernel: Make i386 thread tramplines crash --- kernel/arch/i386/Thread.S | 39 ++++++------------------------------- kernel/arch/x86_64/Thread.S | 2 +- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/kernel/arch/i386/Thread.S b/kernel/arch/i386/Thread.S index 30e8811e8f..d0b6a04f90 100644 --- a/kernel/arch/i386/Thread.S +++ b/kernel/arch/i386/Thread.S @@ -4,44 +4,17 @@ read_ip: popl %eax jmp *%eax -exit_thread_trampoline: - addl $4, %esp - pushl (%esp) - ret - # void start_thread(uint32_t sp, uint32_t ip) .global start_thread start_thread: - movl 8(%esp), %ecx - movl 4(%esp), %esp - movl $0, %ebp - pushl $exit_thread_trampoline - sti - jmp *%ecx + ud2 # void continue_thread(uint32_t sp, uint32_t ip) .global continue_thread continue_thread: - movl 8(%esp), %ecx - movl 4(%esp), %esp - movl $0, %eax - jmp *%ecx + ud2 -# void thread_jump_userspace(uint32_t sp, uint32_t ip) -.global thread_jump_userspace -thread_jump_userspace: - movl $0x23, %eax - 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 +# void thread_userspace_trampoline(uint32_t sp, uint32_t ip, int argc, char** argv, char** envp) +.global thread_userspace_trampoline +thread_userspace_trampoline: + ud2 diff --git a/kernel/arch/x86_64/Thread.S b/kernel/arch/x86_64/Thread.S index 62973ada37..de1e59ab52 100644 --- a/kernel/arch/x86_64/Thread.S +++ b/kernel/arch/x86_64/Thread.S @@ -1,4 +1,4 @@ -# uint64_t read_() +# uint64_t read_ip() .global read_ip read_ip: popq %rax