2 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
6 #include "linux/config.h"
7 #include "linux/sched.h"
8 #include "linux/slab.h"
9 #include "linux/types.h"
10 #include "asm/uaccess.h"
11 #include "asm/ptrace.h"
14 #include "choose-mode.h"
16 #include "mode_kern.h"
20 extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
22 static int do_modify_ldt_tt(int func, void *ptr, unsigned long bytecount)
24 return modify_ldt(func, ptr, bytecount);
29 #ifdef CONFIG_MODE_SKAS
32 #include "skas_ptrace.h"
34 static int do_modify_ldt_skas(int func, void *ptr, unsigned long bytecount)
36 struct ptrace_ldt ldt;
40 ldt = ((struct ptrace_ldt) { .func = func,
42 .bytecount = bytecount });
45 res = ptrace(PTRACE_LDT, userspace_pid[cpu], 0, (unsigned long) &ldt);
52 int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
54 struct user_desc info;
57 void *p = NULL; /* What we pass to host. */
61 case 0x11: /* write_ldt */
62 /* Do this check now to avoid overflows. */
63 if (bytecount != sizeof(struct user_desc)) {
68 if(copy_from_user(&info, ptr, sizeof(info))) {
76 case 2: /* read_ldt */
78 /* The use of info avoids kmalloc on the write case, not on the
80 buf = kmalloc(bytecount, GFP_KERNEL);
92 res = CHOOSE_MODE_PROC(do_modify_ldt_tt, do_modify_ldt_skas, func,
100 /* Modify_ldt was for reading and returned the number of read
102 if(copy_to_user(ptr, p, res))