Skip to content

Commit d0b5e15

Browse files
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 <[email protected]>
1 parent aaeac66 commit d0b5e15

File tree

18 files changed

+148
-814
lines changed

18 files changed

+148
-814
lines changed

arch/um/include/shared/os.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ extern unsigned long long os_makedev(unsigned major, unsigned minor);
174174

175175
/* start_up.c */
176176
extern void os_early_checks(void);
177-
extern void can_do_skas(void);
178177
extern void os_check_bugs(void);
179178
extern void check_host_supports_tls(int *supports_tls, int *tls_min);
180179

@@ -187,7 +186,6 @@ extern int os_process_parent(int pid);
187186
extern void os_stop_process(int pid);
188187
extern void os_kill_process(int pid, int reap_child);
189188
extern void os_kill_ptraced_process(int pid, int reap_child);
190-
extern long os_ptrace_ldt(long pid, long addr, long data);
191189

192190
extern int os_getpid(void);
193191
extern int os_getpgrp(void);

arch/um/include/shared/skas/proc_mm.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

arch/um/include/shared/skas/skas.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
#include <sysdep/ptrace.h>
1010

1111
extern int userspace_pid[];
12-
extern int proc_mm, ptrace_faultinfo, ptrace_ldt;
13-
extern int skas_needs_stub;
1412

1513
extern int user_thread(unsigned long stack, int flags);
1614
extern void new_thread_handler(void);
1715
extern void handle_syscall(struct uml_pt_regs *regs);
18-
extern int new_mm(unsigned long stack);
1916
extern long execute_syscall_skas(void *r);
2017
extern unsigned long current_stub_stack(void);
2118

arch/um/include/shared/skas_ptrace.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

arch/um/kernel/ptrace.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
#include <linux/sched.h>
99
#include <linux/tracehook.h>
1010
#include <asm/uaccess.h>
11-
#include <skas_ptrace.h>
12-
13-
1411

1512
void user_enable_single_step(struct task_struct *child)
1613
{
@@ -104,35 +101,6 @@ long arch_ptrace(struct task_struct *child, long request,
104101
ret = ptrace_set_thread_area(child, addr, vp);
105102
break;
106103

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
136104
default:
137105
ret = ptrace_request(child, request, addr, data);
138106
if (ret == -EIO)

arch/um/kernel/reboot.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,21 @@ void (*pm_power_off)(void);
1515

1616
static void kill_off_processes(void)
1717
{
18-
if (proc_mm)
19-
/*
20-
* FIXME: need to loop over userspace_pids
21-
*/
22-
os_kill_ptraced_process(userspace_pid[0], 1);
23-
else {
24-
struct task_struct *p;
25-
int pid;
26-
27-
read_lock(&tasklist_lock);
28-
for_each_process(p) {
29-
struct task_struct *t;
30-
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);
18+
struct task_struct *p;
19+
int pid;
20+
21+
read_lock(&tasklist_lock);
22+
for_each_process(p) {
23+
struct task_struct *t;
24+
25+
t = find_lock_task_mm(p);
26+
if (!t)
27+
continue;
28+
pid = t->mm->context.id.u.pid;
29+
task_unlock(t);
30+
os_kill_ptraced_process(pid, 1);
3931
}
32+
read_unlock(&tasklist_lock);
4033
}
4134

4235
void uml_cleanup(void)

arch/um/kernel/skas/mmu.c

Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,22 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
5454
unsigned long stack = 0;
5555
int ret = -ENOMEM;
5656

57-
if (skas_needs_stub) {
58-
stack = get_zeroed_page(GFP_KERNEL);
59-
if (stack == 0)
60-
goto out;
61-
}
57+
stack = get_zeroed_page(GFP_KERNEL);
58+
if (stack == 0)
59+
goto out;
6260

6361
to_mm->id.stack = stack;
6462
if (current->mm != NULL && current->mm != &init_mm)
6563
from_mm = &current->mm->context;
6664

67-
if (proc_mm) {
68-
ret = new_mm(stack);
69-
if (ret < 0) {
70-
printk(KERN_ERR "init_new_context_skas - "
71-
"new_mm failed, errno = %d\n", ret);
72-
goto out_free;
73-
}
74-
to_mm->id.u.mm_fd = ret;
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-
}
65+
if (from_mm)
66+
to_mm->id.u.pid = copy_context_skas0(stack,
67+
from_mm->id.u.pid);
68+
else to_mm->id.u.pid = start_userspace(stack);
69+
70+
if (to_mm->id.u.pid < 0) {
71+
ret = to_mm->id.u.pid;
72+
goto out_free;
8673
}
8774

8875
ret = init_new_ldt(to_mm, from_mm);
@@ -105,9 +92,6 @@ void uml_setup_stubs(struct mm_struct *mm)
10592
{
10693
int err, ret;
10794

108-
if (!skas_needs_stub)
109-
return;
110-
11195
ret = init_stub_pte(mm, STUB_CODE,
11296
(unsigned long) &__syscall_stub_start);
11397
if (ret)
@@ -154,25 +138,19 @@ void destroy_context(struct mm_struct *mm)
154138
{
155139
struct mm_context *mmu = &mm->context;
156140

157-
if (proc_mm)
158-
os_close_file(mmu->id.u.mm_fd);
159-
else {
160-
/*
161-
* If init_new_context wasn't called, this will be
162-
* zero, resulting in a kill(0), which will result in the
163-
* whole UML suddenly dying. Also, cover negative and
164-
* 1 cases, since they shouldn't happen either.
165-
*/
166-
if (mmu->id.u.pid < 2) {
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);
141+
/*
142+
* If init_new_context wasn't called, this will be
143+
* zero, resulting in a kill(0), which will result in the
144+
* whole UML suddenly dying. Also, cover negative and
145+
* 1 cases, since they shouldn't happen either.
146+
*/
147+
if (mmu->id.u.pid < 2) {
148+
printk(KERN_ERR "corrupt mm_context - pid = %d\n",
149+
mmu->id.u.pid);
150+
return;
172151
}
152+
os_kill_ptraced_process(mmu->id.u.pid, 1);
173153

174-
if (skas_needs_stub)
175-
free_page(mmu->id.stack);
176-
154+
free_page(mmu->id.stack);
177155
free_ldt(mmu);
178156
}

arch/um/kernel/skas/process.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,6 @@
1010
#include <os.h>
1111
#include <skas.h>
1212

13-
int 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-
3213
extern void start_kernel(void);
3314

3415
static int __init start_kernel_proc(void *unused)
@@ -55,14 +36,6 @@ int __init start_uml(void)
5536
{
5637
stack_protections((unsigned long) &cpu0_irqstack);
5738
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-
}
6639

6740
init_new_thread_signals();
6841

arch/um/kernel/trap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
220220
panic("Segfault with no mm");
221221
}
222222

223-
if (SEGV_IS_FIXABLE(&fi) || SEGV_MAYBE_FIXABLE(&fi))
223+
if (SEGV_IS_FIXABLE(&fi))
224224
err = handle_page_fault(address, ip, is_write, is_user,
225225
&si.si_code);
226226
else {

arch/um/kernel/um_arch.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ int __init linux_main(int argc, char **argv)
268268
unsigned long stack;
269269
unsigned int i;
270270
int add;
271-
char * mode;
272271

273272
for (i = 1; i < argc; i++) {
274273
if ((i == 1) && (argv[i][0] == ' '))
@@ -291,15 +290,6 @@ int __init linux_main(int argc, char **argv)
291290
/* OS sanity checks that need to happen before the kernel runs */
292291
os_early_checks();
293292

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-
303293
brk_start = (unsigned long) sbrk(0);
304294

305295
/*

0 commit comments

Comments
 (0)