diff options
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/Kconfig | 2 | ||||
-rw-r--r-- | arch/um/Makefile-x86_64 | 4 | ||||
-rw-r--r-- | arch/um/include/sysdep-i386/stub.h | 29 | ||||
-rw-r--r-- | arch/um/include/sysdep-x86_64/stub.h | 30 | ||||
-rw-r--r-- | arch/um/kernel/skas/clone.c | 23 | ||||
-rw-r--r-- | arch/um/os-Linux/start_up.c | 22 | ||||
-rw-r--r-- | arch/um/os-Linux/user_syms.c | 5 | ||||
-rw-r--r-- | arch/um/scripts/Makefile.rules | 5 | ||||
-rw-r--r-- | arch/um/sys-i386/Makefile | 8 | ||||
-rw-r--r-- | arch/um/sys-x86_64/Makefile | 5 |
10 files changed, 77 insertions, 56 deletions
diff --git a/arch/um/Kconfig b/arch/um/Kconfig index 563301f..1eb21de 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig @@ -289,6 +289,8 @@ source "arch/um/Kconfig.net" source "drivers/net/Kconfig" +source "drivers/connector/Kconfig" + source "fs/Kconfig" source "security/Kconfig" diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64 index 4f118d5..38df311 100644 --- a/arch/um/Makefile-x86_64 +++ b/arch/um/Makefile-x86_64 @@ -12,3 +12,7 @@ CHECKFLAGS += -m64 ELF_ARCH := i386:x86-64 ELF_FORMAT := elf64-x86-64 + +# Not on all 64-bit distros /lib is a symlink to /lib64. PLD is an example. + +LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64 diff --git a/arch/um/include/sysdep-i386/stub.h b/arch/um/include/sysdep-i386/stub.h index 6ba8cbb..b492b12 100644 --- a/arch/um/include/sysdep-i386/stub.h +++ b/arch/um/include/sysdep-i386/stub.h @@ -6,8 +6,12 @@ #ifndef __SYSDEP_STUB_H #define __SYSDEP_STUB_H +#include <sys/mman.h> #include <asm/ptrace.h> #include <asm/unistd.h> +#include "stub-data.h" +#include "kern_constants.h" +#include "uml-config.h" extern void stub_segv_handler(int sig); extern void stub_clone_handler(void); @@ -76,23 +80,22 @@ static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3, return ret; } -static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, - long arg4, long arg5, long arg6) +static inline void trap_myself(void) { - long ret; - - __asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; " - "int $0x80 ; pop %%ebp" - : "=a" (ret) - : "g" (syscall), "b" (arg1), "c" (arg2), "d" (arg3), - "S" (arg4), "D" (arg5), "0" (arg6)); - - return ret; + __asm("int3"); } -static inline void trap_myself(void) +static inline void remap_stack(int fd, unsigned long offset) { - __asm("int3"); + __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;" + "movl %7, %%ebx ; movl %%eax, (%%ebx)" + : : "g" (STUB_MMAP_NR), "b" (UML_CONFIG_STUB_DATA), + "c" (UM_KERN_PAGE_SIZE), + "d" (PROT_READ | PROT_WRITE), + "S" (MAP_FIXED | MAP_SHARED), "D" (fd), + "a" (offset), + "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err) + : "memory"); } #endif diff --git a/arch/um/include/sysdep-x86_64/stub.h b/arch/um/include/sysdep-x86_64/stub.h index c41689c..92e989f 100644 --- a/arch/um/include/sysdep-x86_64/stub.h +++ b/arch/um/include/sysdep-x86_64/stub.h @@ -6,8 +6,12 @@ #ifndef __SYSDEP_STUB_H #define __SYSDEP_STUB_H +#include <sys/mman.h> #include <asm/unistd.h> #include <sysdep/ptrace_user.h> +#include "stub-data.h" +#include "kern_constants.h" +#include "uml-config.h" extern void stub_segv_handler(int sig); extern void stub_clone_handler(void); @@ -81,23 +85,23 @@ static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3, return ret; } -static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, - long arg4, long arg5, long arg6) +static inline void trap_myself(void) { - long ret; - - __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " - "movq %7, %%r9; " __syscall : "=a" (ret) - : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3), - "g" (arg4), "g" (arg5), "g" (arg6) - : __syscall_clobber, "r10", "r8", "r9" ); - - return ret; + __asm("int3"); } -static inline void trap_myself(void) +static inline void remap_stack(long fd, unsigned long offset) { - __asm("int3"); + __asm__ volatile ("movq %4,%%r10 ; movq %5,%%r8 ; " + "movq %6, %%r9; " __syscall "; movq %7, %%rbx ; " + "movq %%rax, (%%rbx)": + : "a" (STUB_MMAP_NR), "D" (UML_CONFIG_STUB_DATA), + "S" (UM_KERN_PAGE_SIZE), + "d" (PROT_READ | PROT_WRITE), + "g" (MAP_FIXED | MAP_SHARED), "g" (fd), + "g" (offset), + "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err) + : __syscall_clobber, "r10", "r8", "r9" ); } #endif diff --git a/arch/um/kernel/skas/clone.c b/arch/um/kernel/skas/clone.c index cb37ce9..47b812b 100644 --- a/arch/um/kernel/skas/clone.c +++ b/arch/um/kernel/skas/clone.c @@ -18,11 +18,10 @@ * on some systems. */ -#define STUB_DATA(field) (((struct stub_data *) UML_CONFIG_STUB_DATA)->field) - void __attribute__ ((__section__ (".__syscall_stub"))) stub_clone_handler(void) { + struct stub_data *data = (struct stub_data *) UML_CONFIG_STUB_DATA; long err; err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD, @@ -35,17 +34,21 @@ stub_clone_handler(void) if(err) goto out; - err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL, - (long) &STUB_DATA(timer), 0); + err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL, + (long) &data->timer, 0); if(err) goto out; - err = stub_syscall6(STUB_MMAP_NR, UML_CONFIG_STUB_DATA, - UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_SHARED, STUB_DATA(fd), - STUB_DATA(offset)); + remap_stack(data->fd, data->offset); + goto done; + out: - /* save current result. Parent: pid; child: retcode of mmap */ - STUB_DATA(err) = err; + /* save current result. + * Parent: pid; + * child: retcode of mmap already saved and it jumps around this + * assignment + */ + data->err = err; + done: trap_myself(); } diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index 37517d4..29a9e3f 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c @@ -116,16 +116,16 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode, if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) { int exit_with = WEXITSTATUS(status); if (exit_with == 2) - printk("check_ptrace : child exited with status 2. " + printf("check_ptrace : child exited with status 2. " "Serious trouble happening! Try updating your " "host skas patch!\nDisabling SYSEMU support."); - printk("check_ptrace : child exited with exitcode %d, while " + printf("check_ptrace : child exited with exitcode %d, while " "expecting %d; status 0x%x", exit_with, exitcode, status); if (mustpanic) panic("\n"); else - printk("\n"); + printf("\n"); ret = -1; } @@ -183,7 +183,7 @@ static void __init check_sysemu(void) void *stack; int pid, n, status, count=0; - printk("Checking syscall emulation patch for ptrace..."); + printf("Checking syscall emulation patch for ptrace..."); sysemu_supported = 0; pid = start_ptraced_child(&stack); @@ -207,10 +207,10 @@ static void __init check_sysemu(void) goto fail_stopped; sysemu_supported = 1; - printk("OK\n"); + printf("OK\n"); set_using_sysemu(!force_sysemu_disabled); - printk("Checking advanced syscall emulation patch for ptrace..."); + printf("Checking advanced syscall emulation patch for ptrace..."); pid = start_ptraced_child(&stack); if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0, @@ -246,7 +246,7 @@ static void __init check_sysemu(void) goto fail_stopped; sysemu_supported = 2; - printk("OK\n"); + printf("OK\n"); if ( !force_sysemu_disabled ) set_using_sysemu(sysemu_supported); @@ -255,7 +255,7 @@ static void __init check_sysemu(void) fail: stop_ptraced_child(pid, stack, 1, 0); fail_stopped: - printk("missing\n"); + printf("missing\n"); } static void __init check_ptrace(void) @@ -263,7 +263,7 @@ static void __init check_ptrace(void) void *stack; int pid, syscall, n, status; - printk("Checking that ptrace can change system call numbers..."); + printf("Checking that ptrace can change system call numbers..."); pid = start_ptraced_child(&stack); if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) @@ -292,7 +292,7 @@ static void __init check_ptrace(void) } } stop_ptraced_child(pid, stack, 0, 1); - printk("OK\n"); + printf("OK\n"); check_sysemu(); } @@ -472,6 +472,8 @@ int can_do_skas(void) int have_devanon = 0; +/* Runs on boot kernel stack - already safe to use printk. */ + void check_devanon(void) { int fd; diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c index 56d3f87..8da6ab3 100644 --- a/arch/um/os-Linux/user_syms.c +++ b/arch/um/os-Linux/user_syms.c @@ -34,6 +34,11 @@ EXPORT_SYMBOL(strstr); int sym(void); \ EXPORT_SYMBOL(sym); +extern void readdir64(void) __attribute__((weak)); +EXPORT_SYMBOL(readdir64); +extern void truncate64(void) __attribute__((weak)); +EXPORT_SYMBOL(truncate64); + #ifdef SUBARCH_i386 EXPORT_SYMBOL(vsyscall_ehdr); EXPORT_SYMBOL(vsyscall_end); diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules index b3fbf12..2e41cab 100644 --- a/arch/um/scripts/Makefile.rules +++ b/arch/um/scripts/Makefile.rules @@ -21,11 +21,6 @@ define unprofile endef -# The stubs and unmap.o can't try to call mcount or update basic block data -define unprofile - $(patsubst -pg,,$(patsubst -fprofile-arcs -ftest-coverage,,$(1))) -endef - # cmd_make_link checks to see if the $(foo-dir) variable starts with a /. If # so, it's considered to be a path relative to $(srcdir) rather than # $(srcdir)/arch/$(SUBARCH). This is because x86_64 wants to get ldt.c from diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile index 150059d..f5fd5b0 100644 --- a/arch/um/sys-i386/Makefile +++ b/arch/um/sys-i386/Makefile @@ -1,6 +1,8 @@ -obj-y = bitops.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \ - ptrace_user.o semaphore.o signal.o sigcontext.o stub.o stub_segv.o \ - syscalls.o sysrq.o sys_call_table.o +obj-y := bitops.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \ + ptrace_user.o semaphore.o signal.o sigcontext.o syscalls.o sysrq.o \ + sys_call_table.o + +obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o obj-$(CONFIG_HIGHMEM) += highmem.o obj-$(CONFIG_MODULES) += module.o diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile index 00b2025..a351091 100644 --- a/arch/um/sys-x86_64/Makefile +++ b/arch/um/sys-x86_64/Makefile @@ -6,8 +6,9 @@ #XXX: why into lib-y? lib-y = bitops.o bugs.o csum-partial.o delay.o fault.o ldt.o mem.o memcpy.o \ - ptrace.o ptrace_user.o sigcontext.o signal.o stub.o \ - stub_segv.o syscalls.o syscall_table.o sysrq.o thunk.o + ptrace.o ptrace_user.o sigcontext.o signal.o syscalls.o \ + syscall_table.o sysrq.o thunk.o +lib-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o obj-y := ksyms.o obj-$(CONFIG_MODULES) += module.o um_module.o |