[libposix-development] [PATCH 2/2] x86_32: use 'int 0x80' for system calls to improve protability
Status: Pre-Alpha
Brought to you by:
hdante
From: Kirill A. S. <ki...@sh...> - 2009-06-26 14:44:20
|
Not every kernel provide __kernel_vsyscall. It's possible to add configuration option later. Signed-off-by: Kirill A. Shutemov <ki...@sh...> --- runtime/linux/x86_32/architecture_init.c | 22 +--------------------- system/linux/x86_32/system_calls.S | 17 ++--------------- 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/runtime/linux/x86_32/architecture_init.c b/runtime/linux/x86_32/architecture_init.c index f080dc4..f3fb6e6 100644 --- a/runtime/linux/x86_32/architecture_init.c +++ b/runtime/linux/x86_32/architecture_init.c @@ -27,28 +27,8 @@ POSSIBILITY OF SUCH DAMAGE. #include <stddef.h> #include "runtime.h" -void (*kernel_vsyscall)(); - -/* AT_SYSINFO entry has the vsyscall address */ -#define AT_SYSINFO 32 - -void set_kernel_vsyscall(const auxv_t *auxv) -{ - if (auxv != NULL) { - const auxv_t *auxv_walk; - for (auxv_walk = auxv; auxv_walk->a_type != 0; auxv_walk++) { - if (auxv_walk->a_type == AT_SYSINFO) { - kernel_vsyscall = auxv_walk->a_un.a_fcn; - return; - - } - } - // ERROR: AT_SYSINFO entry not found - } -} - void architecture_init(int argc, const char **argv, const char **envp, const auxv_t *auxv) { - set_kernel_vsyscall(auxv); + /* Do nothing */ } diff --git a/system/linux/x86_32/system_calls.S b/system/linux/x86_32/system_calls.S index 8e1d6f9..f11f8ca 100644 --- a/system/linux/x86_32/system_calls.S +++ b/system/linux/x86_32/system_calls.S @@ -36,8 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. Paramenter sequence is: %ebx, %ecx, %edx, %esi, %edi and %ebp See, for example: http://www.linuxjournal.com/article/4048 - - TODO: remove calculation for kernel_vsyscall (use a fixed address) */ @@ -45,12 +43,9 @@ syscall1: pushl %ebp movl %esp, %ebp pushl %ebx - call get_abs_address - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl kernel_vsyscall@GOT(%ebx), %ecx movl 8(%ebp), %eax movl 12(%ebp), %ebx - call *(%ecx) + int $0x80 popl %ebx popl %ebp ret @@ -60,20 +55,12 @@ syscall3: movl %esp, %ebp pushl %edi pushl %ebx - call get_abs_address - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl kernel_vsyscall@GOT(%ebx), %edi movl 8(%ebp), %eax movl 12(%ebp), %ebx movl 16(%ebp), %ecx movl 20(%ebp), %edx - call *(%edi) + int $0x80 popl %ebx popl %edi popl %ebp ret - -get_abs_address: - mov (%esp), %ebx - ret - -- 1.6.3.3 |