aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/kernel
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2015-03-18 16:31:27 -0400
committerRichard Weinberger <richard@nod.at>2015-04-13 15:00:53 -0400
commitd0b5e15f0c0fdd759dd3dd48dc2dc2e7199e0da0 (patch)
tree7b833b85c0e2eabf6b38d8b94875b430554afae7 /arch/um/kernel
parentaaeac66b1a02d399ec8ee63e8d617c1d601ea353 (diff)
um: Remove SKAS3/4 support
Before we had SKAS0 UML had two modes of operation TT (tracing thread) and SKAS3/4 (separated kernel address space). TT was known to be insecure and got removed a long time ago. SKAS3/4 required a few (3 or 4) patches on the host side which never went mainline. The last host patch is 10 years old. With SKAS0 mode (separated kernel address space using 0 host patches), default since 2005, SKAS3/4 is obsolete and can be removed. Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/kernel')
-rw-r--r--arch/um/kernel/ptrace.c32
-rw-r--r--arch/um/kernel/reboot.c35
-rw-r--r--arch/um/kernel/skas/mmu.c68
-rw-r--r--arch/um/kernel/skas/process.c27
-rw-r--r--arch/um/kernel/trap.c2
-rw-r--r--arch/um/kernel/um_arch.c10
6 files changed, 38 insertions, 136 deletions
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 62435ef003d9..174ee5017264 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -8,9 +8,6 @@
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/tracehook.h> 9#include <linux/tracehook.h>
10#include <asm/uaccess.h> 10#include <asm/uaccess.h>
11#include <skas_ptrace.h>
12
13
14 11
15void user_enable_single_step(struct task_struct *child) 12void user_enable_single_step(struct task_struct *child)
16{ 13{
@@ -104,35 +101,6 @@ long arch_ptrace(struct task_struct *child, long request,
104 ret = ptrace_set_thread_area(child, addr, vp); 101 ret = ptrace_set_thread_area(child, addr, vp);
105 break; 102 break;
106 103
107 case PTRACE_FAULTINFO: {
108 /*
109 * Take the info from thread->arch->faultinfo,
110 * but transfer max. sizeof(struct ptrace_faultinfo).
111 * On i386, ptrace_faultinfo is smaller!
112 */
113 ret = copy_to_user(p, &child->thread.arch.faultinfo,
114 sizeof(struct ptrace_faultinfo)) ?
115 -EIO : 0;
116 break;
117 }
118
119#ifdef PTRACE_LDT
120 case PTRACE_LDT: {
121 struct ptrace_ldt ldt;
122
123 if (copy_from_user(&ldt, p, sizeof(ldt))) {
124 ret = -EIO;
125 break;
126 }
127
128 /*
129 * This one is confusing, so just punt and return -EIO for
130 * now
131 */
132 ret = -EIO;
133 break;
134 }
135#endif
136 default: 104 default:
137 ret = ptrace_request(child, request, addr, data); 105 ret = ptrace_request(child, request, addr, data);
138 if (ret == -EIO) 106 if (ret == -EIO)
diff --git a/arch/um/kernel/reboot.c b/arch/um/kernel/reboot.c
index ced8903921ae..9bdf67a092a5 100644
--- a/arch/um/kernel/reboot.c
+++ b/arch/um/kernel/reboot.c
@@ -15,28 +15,21 @@ void (*pm_power_off)(void);
15 15
16static void kill_off_processes(void) 16static void kill_off_processes(void)
17{ 17{
18 if (proc_mm) 18 struct task_struct *p;
19 /* 19 int pid;
20 * FIXME: need to loop over userspace_pids 20
21 */ 21 read_lock(&tasklist_lock);
22 os_kill_ptraced_process(userspace_pid[0], 1); 22 for_each_process(p) {
23 else { 23 struct task_struct *t;
24 struct task_struct *p; 24
25 int pid; 25 t = find_lock_task_mm(p);
26 26 if (!t)
27 read_lock(&tasklist_lock); 27 continue;
28 for_each_process(p) { 28 pid = t->mm->context.id.u.pid;
29 struct task_struct *t; 29 task_unlock(t);
30 30 os_kill_ptraced_process(pid, 1);
31 t = find_lock_task_mm(p);
32 if (!t)
33 continue;
34 pid = t->mm->context.id.u.pid;
35 task_unlock(t);
36 os_kill_ptraced_process(pid, 1);
37 }
38 read_unlock(&tasklist_lock);
39 } 31 }
32 read_unlock(&tasklist_lock);
40} 33}
41 34
42void uml_cleanup(void) 35void uml_cleanup(void)
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c
index 007d5503f49b..94abdcc1d6ad 100644
--- a/arch/um/kernel/skas/mmu.c
+++ b/arch/um/kernel/skas/mmu.c
@@ -54,35 +54,22 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
54 unsigned long stack = 0; 54 unsigned long stack = 0;
55 int ret = -ENOMEM; 55 int ret = -ENOMEM;
56 56
57 if (skas_needs_stub) { 57 stack = get_zeroed_page(GFP_KERNEL);
58 stack = get_zeroed_page(GFP_KERNEL); 58 if (stack == 0)
59 if (stack == 0) 59 goto out;
60 goto out;
61 }
62 60
63 to_mm->id.stack = stack; 61 to_mm->id.stack = stack;
64 if (current->mm != NULL && current->mm != &init_mm) 62 if (current->mm != NULL && current->mm != &init_mm)
65 from_mm = &current->mm->context; 63 from_mm = &current->mm->context;
66 64
67 if (proc_mm) { 65 if (from_mm)
68 ret = new_mm(stack); 66 to_mm->id.u.pid = copy_context_skas0(stack,
69 if (ret < 0) { 67 from_mm->id.u.pid);
70 printk(KERN_ERR "init_new_context_skas - " 68 else to_mm->id.u.pid = start_userspace(stack);
71 "new_mm failed, errno = %d\n", ret); 69
72 goto out_free; 70 if (to_mm->id.u.pid < 0) {
73 } 71 ret = to_mm->id.u.pid;
74 to_mm->id.u.mm_fd = ret; 72 goto out_free;
75 }
76 else {
77 if (from_mm)
78 to_mm->id.u.pid = copy_context_skas0(stack,
79 from_mm->id.u.pid);
80 else to_mm->id.u.pid = start_userspace(stack);
81
82 if (to_mm->id.u.pid < 0) {
83 ret = to_mm->id.u.pid;
84 goto out_free;
85 }
86 } 73 }
87 74
88 ret = init_new_ldt(to_mm, from_mm); 75 ret = init_new_ldt(to_mm, from_mm);
@@ -105,9 +92,6 @@ void uml_setup_stubs(struct mm_struct *mm)
105{ 92{
106 int err, ret; 93 int err, ret;
107 94
108 if (!skas_needs_stub)
109 return;
110
111 ret = init_stub_pte(mm, STUB_CODE, 95 ret = init_stub_pte(mm, STUB_CODE,
112 (unsigned long) &__syscall_stub_start); 96 (unsigned long) &__syscall_stub_start);
113 if (ret) 97 if (ret)
@@ -154,25 +138,19 @@ void destroy_context(struct mm_struct *mm)
154{ 138{
155 struct mm_context *mmu = &mm->context; 139 struct mm_context *mmu = &mm->context;
156 140
157 if (proc_mm) 141 /*
158 os_close_file(mmu->id.u.mm_fd); 142 * If init_new_context wasn't called, this will be
159 else { 143 * zero, resulting in a kill(0), which will result in the
160 /* 144 * whole UML suddenly dying. Also, cover negative and
161 * If init_new_context wasn't called, this will be 145 * 1 cases, since they shouldn't happen either.
162 * zero, resulting in a kill(0), which will result in the 146 */
163 * whole UML suddenly dying. Also, cover negative and 147 if (mmu->id.u.pid < 2) {
164 * 1 cases, since they shouldn't happen either. 148 printk(KERN_ERR "corrupt mm_context - pid = %d\n",
165 */ 149 mmu->id.u.pid);
166 if (mmu->id.u.pid < 2) { 150 return;
167 printk(KERN_ERR "corrupt mm_context - pid = %d\n",
168 mmu->id.u.pid);
169 return;
170 }
171 os_kill_ptraced_process(mmu->id.u.pid, 1);
172 } 151 }
152 os_kill_ptraced_process(mmu->id.u.pid, 1);
173 153
174 if (skas_needs_stub) 154 free_page(mmu->id.stack);
175 free_page(mmu->id.stack);
176
177 free_ldt(mmu); 155 free_ldt(mmu);
178} 156}
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
index 4da11b3c8ddb..082955d694f3 100644
--- a/arch/um/kernel/skas/process.c
+++ b/arch/um/kernel/skas/process.c
@@ -10,25 +10,6 @@
10#include <os.h> 10#include <os.h>
11#include <skas.h> 11#include <skas.h>
12 12
13int new_mm(unsigned long stack)
14{
15 int fd, err;
16
17 fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0);
18 if (fd < 0)
19 return fd;
20
21 if (skas_needs_stub) {
22 err = map_stub_pages(fd, STUB_CODE, STUB_DATA, stack);
23 if (err) {
24 os_close_file(fd);
25 return err;
26 }
27 }
28
29 return fd;
30}
31
32extern void start_kernel(void); 13extern void start_kernel(void);
33 14
34static int __init start_kernel_proc(void *unused) 15static int __init start_kernel_proc(void *unused)
@@ -55,14 +36,6 @@ int __init start_uml(void)
55{ 36{
56 stack_protections((unsigned long) &cpu0_irqstack); 37 stack_protections((unsigned long) &cpu0_irqstack);
57 set_sigstack(cpu0_irqstack, THREAD_SIZE); 38 set_sigstack(cpu0_irqstack, THREAD_SIZE);
58 if (proc_mm) {
59 userspace_pid[0] = start_userspace(0);
60 if (userspace_pid[0] < 0) {
61 printf("start_uml - start_userspace returned %d\n",
62 userspace_pid[0]);
63 exit(1);
64 }
65 }
66 39
67 init_new_thread_signals(); 40 init_new_thread_signals();
68 41
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
index 209617302df8..8e4daf44e980 100644
--- a/arch/um/kernel/trap.c
+++ b/arch/um/kernel/trap.c
@@ -220,7 +220,7 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
220 panic("Segfault with no mm"); 220 panic("Segfault with no mm");
221 } 221 }
222 222
223 if (SEGV_IS_FIXABLE(&fi) || SEGV_MAYBE_FIXABLE(&fi)) 223 if (SEGV_IS_FIXABLE(&fi))
224 err = handle_page_fault(address, ip, is_write, is_user, 224 err = handle_page_fault(address, ip, is_write, is_user,
225 &si.si_code); 225 &si.si_code);
226 else { 226 else {
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 9274eae6ae7b..dbd5bda1f184 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -268,7 +268,6 @@ int __init linux_main(int argc, char **argv)
268 unsigned long stack; 268 unsigned long stack;
269 unsigned int i; 269 unsigned int i;
270 int add; 270 int add;
271 char * mode;
272 271
273 for (i = 1; i < argc; i++) { 272 for (i = 1; i < argc; i++) {
274 if ((i == 1) && (argv[i][0] == ' ')) 273 if ((i == 1) && (argv[i][0] == ' '))
@@ -291,15 +290,6 @@ int __init linux_main(int argc, char **argv)
291 /* OS sanity checks that need to happen before the kernel runs */ 290 /* OS sanity checks that need to happen before the kernel runs */
292 os_early_checks(); 291 os_early_checks();
293 292
294 can_do_skas();
295
296 if (proc_mm && ptrace_faultinfo)
297 mode = "SKAS3";
298 else
299 mode = "SKAS0";
300
301 printf("UML running in %s mode\n", mode);
302
303 brk_start = (unsigned long) sbrk(0); 293 brk_start = (unsigned long) sbrk(0);
304 294
305 /* 295 /*