aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-i386/ldt.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/sys-i386/ldt.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/um/sys-i386/ldt.c')
-rw-r--r--arch/um/sys-i386/ldt.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
new file mode 100644
index 000000000000..31bcb2f997d4
--- /dev/null
+++ b/arch/um/sys-i386/ldt.c
@@ -0,0 +1,98 @@
1/*
2 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/config.h"
7#include "linux/slab.h"
8#include "asm/uaccess.h"
9#include "asm/ptrace.h"
10#include "choose-mode.h"
11#include "kern.h"
12
13#ifdef CONFIG_MODE_TT
14extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
15
16/* XXX this needs copy_to_user and copy_from_user */
17
18int sys_modify_ldt_tt(int func, void __user *ptr, unsigned long bytecount)
19{
20 if (!access_ok(VERIFY_READ, ptr, bytecount))
21 return -EFAULT;
22
23 return modify_ldt(func, ptr, bytecount);
24}
25#endif
26
27#ifdef CONFIG_MODE_SKAS
28extern int userspace_pid;
29
30#include "skas_ptrace.h"
31
32int sys_modify_ldt_skas(int func, void __user *ptr, unsigned long bytecount)
33{
34 struct ptrace_ldt ldt;
35 void *buf;
36 int res, n;
37
38 buf = kmalloc(bytecount, GFP_KERNEL);
39 if(buf == NULL)
40 return(-ENOMEM);
41
42 res = 0;
43
44 switch(func){
45 case 1:
46 case 0x11:
47 res = copy_from_user(buf, ptr, bytecount);
48 break;
49 }
50
51 if(res != 0){
52 res = -EFAULT;
53 goto out;
54 }
55
56 ldt = ((struct ptrace_ldt) { .func = func,
57 .ptr = buf,
58 .bytecount = bytecount });
59 res = ptrace(PTRACE_LDT, userspace_pid, 0, (unsigned long) &ldt);
60 if(res < 0)
61 goto out;
62
63 switch(func){
64 case 0:
65 case 2:
66 n = res;
67 res = copy_to_user(ptr, buf, n);
68 if(res != 0)
69 res = -EFAULT;
70 else
71 res = n;
72 break;
73 }
74
75 out:
76 kfree(buf);
77 return(res);
78}
79#endif
80
81int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
82{
83 return(CHOOSE_MODE_PROC(sys_modify_ldt_tt, sys_modify_ldt_skas, func,
84 ptr, bytecount));
85}
86
87
88
89/*
90 * Overrides for Emacs so that we follow Linus's tabbing style.
91 * Emacs will notice this stuff at the end of the file and automatically
92 * adjust the settings for this buffer only. This must remain at the end
93 * of the file.
94 * ---------------------------------------------------------------------------
95 * Local variables:
96 * c-file-style: "linux"
97 * End:
98 */