aboutsummaryrefslogtreecommitdiff
path: root/arch/um/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/kernel')
-rw-r--r--arch/um/kernel/exitcode.c2
-rw-r--r--arch/um/kernel/helper.c14
-rw-r--r--arch/um/kernel/process.c83
-rw-r--r--arch/um/kernel/process_kern.c2
-rw-r--r--arch/um/kernel/skas/process.c2
-rw-r--r--arch/um/kernel/skas/syscall_user.c4
-rw-r--r--arch/um/kernel/skas/trap_user.c1
-rw-r--r--arch/um/kernel/time_kern.c5
-rw-r--r--arch/um/kernel/um_arch.c19
9 files changed, 84 insertions, 48 deletions
diff --git a/arch/um/kernel/exitcode.c b/arch/um/kernel/exitcode.c
index 0ea87f24b36..d21ebad666b 100644
--- a/arch/um/kernel/exitcode.c
+++ b/arch/um/kernel/exitcode.c
@@ -48,7 +48,7 @@ static int make_proc_exitcode(void)
ent = create_proc_entry("exitcode", 0600, &proc_root);
if(ent == NULL){
- printk("make_proc_exitcode : Failed to register "
+ printk(KERN_WARNING "make_proc_exitcode : Failed to register "
"/proc/exitcode\n");
return(0);
}
diff --git a/arch/um/kernel/helper.c b/arch/um/kernel/helper.c
index 13b1f5c2f7e..f83e1e8e239 100644
--- a/arch/um/kernel/helper.c
+++ b/arch/um/kernel/helper.c
@@ -13,6 +13,7 @@
#include "user.h"
#include "kern_util.h"
#include "user_util.h"
+#include "helper.h"
#include "os.h"
struct helper_data {
@@ -149,7 +150,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
return(pid);
}
-int helper_wait(int pid, int block)
+int helper_wait(int pid)
{
int ret;
@@ -160,14 +161,3 @@ int helper_wait(int pid, int block)
}
return(ret);
}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index c45a60e9c92..67acd92c532 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -131,7 +131,7 @@ int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
return(arg.pid);
}
-static int ptrace_child(void)
+static int ptrace_child(void *arg)
{
int ret;
int pid = os_getpid(), ppid = getppid();
@@ -160,16 +160,20 @@ static int ptrace_child(void)
_exit(ret);
}
-static int start_ptraced_child(void)
+static int start_ptraced_child(void **stack_out)
{
+ void *stack;
+ unsigned long sp;
int pid, n, status;
- pid = fork();
- if(pid == 0)
- ptrace_child();
-
+ stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if(stack == MAP_FAILED)
+ panic("check_ptrace : mmap failed, errno = %d", errno);
+ sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *);
+ pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
if(pid < 0)
- panic("check_ptrace : fork failed, errno = %d", errno);
+ panic("check_ptrace : clone failed, errno = %d", errno);
CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
if(n < 0)
panic("check_ptrace : wait failed, errno = %d", errno);
@@ -177,6 +181,7 @@ static int start_ptraced_child(void)
panic("check_ptrace : expected SIGSTOP, got status = %d",
status);
+ *stack_out = stack;
return(pid);
}
@@ -184,12 +189,12 @@ static int start_ptraced_child(void)
* just avoid using sysemu, not panic, but only if SYSEMU features are broken.
* So only for SYSEMU features we test mustpanic, while normal host features
* must work anyway!*/
-static int stop_ptraced_child(int pid, int exitcode, int mustexit)
+static int stop_ptraced_child(int pid, void *stack, int exitcode, int mustpanic)
{
int status, n, ret = 0;
if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
- panic("stop_ptraced_child : ptrace failed, errno = %d", errno);
+ panic("check_ptrace : ptrace failed, errno = %d", errno);
CATCH_EINTR(n = waitpid(pid, &status, 0));
if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) {
int exit_with = WEXITSTATUS(status);
@@ -200,24 +205,40 @@ static int stop_ptraced_child(int pid, int exitcode, int mustexit)
printk("check_ptrace : child exited with exitcode %d, while "
"expecting %d; status 0x%x", exit_with,
exitcode, status);
- if (mustexit)
+ if (mustpanic)
panic("\n");
else
printk("\n");
ret = -1;
}
+ if(munmap(stack, PAGE_SIZE) < 0)
+ panic("check_ptrace : munmap failed, errno = %d", errno);
return ret;
}
static int force_sysemu_disabled = 0;
+int ptrace_faultinfo = 1;
+int proc_mm = 1;
+
+static int __init skas0_cmd_param(char *str, int* add)
+{
+ ptrace_faultinfo = proc_mm = 0;
+ return 0;
+}
+
static int __init nosysemu_cmd_param(char *str, int* add)
{
force_sysemu_disabled = 1;
return 0;
}
+__uml_setup("skas0", skas0_cmd_param,
+ "skas0\n"
+ " Disables SKAS3 usage, so that SKAS0 is used, unless you \n"
+ " specify mode=tt.\n\n");
+
__uml_setup("nosysemu", nosysemu_cmd_param,
"nosysemu\n"
" Turns off syscall emulation patch for ptrace (SYSEMU) on.\n"
@@ -228,11 +249,12 @@ __uml_setup("nosysemu", nosysemu_cmd_param,
static void __init check_sysemu(void)
{
+ void *stack;
int pid, syscall, n, status, count=0;
printk("Checking syscall emulation patch for ptrace...");
sysemu_supported = 0;
- pid = start_ptraced_child();
+ pid = start_ptraced_child(&stack);
if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0)
goto fail;
@@ -250,7 +272,7 @@ static void __init check_sysemu(void)
panic("check_sysemu : failed to modify system "
"call return, errno = %d", errno);
- if (stop_ptraced_child(pid, 0, 0) < 0)
+ if (stop_ptraced_child(pid, stack, 0, 0) < 0)
goto fail_stopped;
sysemu_supported = 1;
@@ -258,7 +280,7 @@ static void __init check_sysemu(void)
set_using_sysemu(!force_sysemu_disabled);
printk("Checking advanced syscall emulation patch for ptrace...");
- pid = start_ptraced_child();
+ pid = start_ptraced_child(&stack);
while(1){
count++;
if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0)
@@ -283,7 +305,7 @@ static void __init check_sysemu(void)
break;
}
}
- if (stop_ptraced_child(pid, 0, 0) < 0)
+ if (stop_ptraced_child(pid, stack, 0, 0) < 0)
goto fail_stopped;
sysemu_supported = 2;
@@ -294,17 +316,18 @@ static void __init check_sysemu(void)
return;
fail:
- stop_ptraced_child(pid, 1, 0);
+ stop_ptraced_child(pid, stack, 1, 0);
fail_stopped:
printk("missing\n");
}
void __init check_ptrace(void)
{
+ void *stack;
int pid, syscall, n, status;
printk("Checking that ptrace can change system call numbers...");
- pid = start_ptraced_child();
+ pid = start_ptraced_child(&stack);
if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)
panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno);
@@ -331,7 +354,7 @@ void __init check_ptrace(void)
break;
}
}
- stop_ptraced_child(pid, 0, 1);
+ stop_ptraced_child(pid, stack, 0, 1);
printk("OK\n");
check_sysemu();
}
@@ -359,22 +382,22 @@ void forward_pending_sigio(int target)
kill(target, SIGIO);
}
-int ptrace_faultinfo = 0;
-int proc_mm = 1;
-
extern void *__syscall_stub_start, __syscall_stub_end;
#ifdef UML_CONFIG_MODE_SKAS
+
static inline void check_skas3_ptrace_support(void)
{
struct ptrace_faultinfo fi;
+ void *stack;
int pid, n;
printf("Checking for the skas3 patch in the host...");
- pid = start_ptraced_child();
+ pid = start_ptraced_child(&stack);
n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi);
if (n < 0) {
+ ptrace_faultinfo = 0;
if(errno == EIO)
printf("not found\n");
else {
@@ -382,12 +405,14 @@ static inline void check_skas3_ptrace_support(void)
}
}
else {
- ptrace_faultinfo = 1;
- printf("found\n");
+ if (!ptrace_faultinfo)
+ printf("found but disabled on command line\n");
+ else
+ printf("found\n");
}
init_registers(pid);
- stop_ptraced_child(pid, 1, 1);
+ stop_ptraced_child(pid, stack, 1, 1);
}
int can_do_skas(void)
@@ -396,13 +421,13 @@ int can_do_skas(void)
if (os_access("/proc/mm", OS_ACC_W_OK) < 0) {
proc_mm = 0;
printf("not found\n");
- goto out;
- }
- else {
- printf("found\n");
+ } else {
+ if (!proc_mm)
+ printf("found but disabled on command line\n");
+ else
+ printf("found\n");
}
-out:
check_skas3_ptrace_support();
return 1;
}
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c
index d4036ed680b..c23d8a08d0f 100644
--- a/arch/um/kernel/process_kern.c
+++ b/arch/um/kernel/process_kern.c
@@ -412,7 +412,7 @@ int __init make_proc_sysemu(void)
if (ent == NULL)
{
- printk("Failed to register /proc/sysemu\n");
+ printk(KERN_WARNING "Failed to register /proc/sysemu\n");
return(0);
}
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
index ba671dab887..6dd9e5bf18e 100644
--- a/arch/um/kernel/skas/process.c
+++ b/arch/um/kernel/skas/process.c
@@ -64,7 +64,7 @@ void wait_stub_done(int pid, int sig, char * fname)
(WSTOPSIG(status) == SIGVTALRM));
if((n < 0) || !WIFSTOPPED(status) ||
- (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status != SIGTRAP))){
+ (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){
panic("%s : failed to wait for SIGUSR1/SIGTRAP, "
"pid = %d, n = %d, errno = %d, status = 0x%x\n",
fname, pid, n, errno, status);
diff --git a/arch/um/kernel/skas/syscall_user.c b/arch/um/kernel/skas/syscall_user.c
index 2828e6e3772..6b066497014 100644
--- a/arch/um/kernel/skas/syscall_user.c
+++ b/arch/um/kernel/skas/syscall_user.c
@@ -15,7 +15,7 @@
void handle_syscall(union uml_pt_regs *regs)
{
long result;
-#if UML_CONFIG_SYSCALL_DEBUG
+#ifdef UML_CONFIG_SYSCALL_DEBUG
int index;
index = record_syscall_start(UPT_SYSCALL_NR(regs));
@@ -27,7 +27,7 @@ void handle_syscall(union uml_pt_regs *regs)
REGS_SET_SYSCALL_RETURN(regs->skas.regs, result);
syscall_trace(regs, 1);
-#if UML_CONFIG_SYSCALL_DEBUG
+#ifdef UML_CONFIG_SYSCALL_DEBUG
record_syscall_end(index, result);
#endif
}
diff --git a/arch/um/kernel/skas/trap_user.c b/arch/um/kernel/skas/trap_user.c
index 0dee1d95c80..9950a6716fe 100644
--- a/arch/um/kernel/skas/trap_user.c
+++ b/arch/um/kernel/skas/trap_user.c
@@ -58,7 +58,6 @@ void user_signal(int sig, union uml_pt_regs *regs, int pid)
int segv = ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
(sig == SIGILL) || (sig == SIGTRAP));
- regs->skas.is_user = 1;
if (segv)
get_skas_faultinfo(pid, &regs->skas.faultinfo);
info = &sig_info[sig];
diff --git a/arch/um/kernel/time_kern.c b/arch/um/kernel/time_kern.c
index a8b4ef601f5..4e08f7545d6 100644
--- a/arch/um/kernel/time_kern.c
+++ b/arch/um/kernel/time_kern.c
@@ -137,7 +137,10 @@ long um_stime(int __user *tptr)
void timer_handler(int sig, union uml_pt_regs *regs)
{
local_irq_disable();
- update_process_times(CHOOSE_MODE(user_context(UPT_SP(regs)), (regs)->skas.is_user));
+ irq_enter();
+ update_process_times(CHOOSE_MODE(user_context(UPT_SP(regs)),
+ (regs)->skas.is_user));
+ irq_exit();
local_irq_enable();
if(current_thread->cpu == 0)
timer_irq(regs);
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 8736d098f0e..ca2bb6f09a7 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -38,6 +38,9 @@
#include "choose-mode.h"
#include "mode_kern.h"
#include "mode.h"
+#ifdef UML_CONFIG_MODE_SKAS
+#include "skas.h"
+#endif
#define DEFAULT_COMMAND_LINE "root=98:0"
@@ -318,6 +321,7 @@ int linux_main(int argc, char **argv)
unsigned long avail, diff;
unsigned long virtmem_size, max_physmem;
unsigned int i, add;
+ char * mode;
for (i = 1; i < argc; i++){
if((i == 1) && (argv[i][0] == ' ')) continue;
@@ -338,6 +342,21 @@ int linux_main(int argc, char **argv)
exit(1);
}
#endif
+
+#ifndef CONFIG_MODE_SKAS
+ mode = "TT";
+#else
+ /* Show to the user the result of selection */
+ if (mode_tt)
+ mode = "TT";
+ else if (proc_mm && ptrace_faultinfo)
+ mode = "SKAS3";
+ else
+ mode = "SKAS0";
+#endif
+
+ printf("UML running in %s mode\n", mode);
+
uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0,
&host_task_size, &task_size);