7 #include <linux/sched.h>
8 #include <linux/slab.h>
9 #include <asm/unistd.h>
13 #include <skas_ptrace.h>
38 mm_idp != &
current->active_mm->context.id)
46 .bytecount =
sizeof(*desc)};
65 (
sizeof(*desc) +
sizeof(
long) - 1) &
70 (
unsigned long)stub_addr,
84 mm_idp != &
current->active_mm->context.id)
91 static long read_ldt_from_host(
void __user *
ptr,
unsigned long bytecount)
136 static int read_ldt(
void __user * ptr,
unsigned long bytecount)
149 return read_ldt_from_host(ptr, bytecount);
154 if (size > bytecount)
165 if (size > bytecount)
177 if (bytecount == 0 || err == -
EFAULT)
187 static int read_default_ldt(
void __user * ptr,
unsigned long bytecount)
206 static int write_ldt(
void __user * ptr,
unsigned long bytecount,
int func)
216 if (bytecount !=
sizeof(ldt_info))
223 if (ldt_info.entry_number >= LDT_ENTRIES)
225 if (ldt_info.contents == 3) {
228 if (ldt_info.seg_not_present == 0)
238 else if (ptrace_ldt) {
245 ldt_info.entry_number >= LDT_DIRECT_ENTRIES) {
257 memset(&ldt_info, 0,
sizeof(ldt_info));
265 sizeof(entry0)*(LDT_DIRECT_ENTRIES-1));
274 ldt_p = ldt->
u.
entries + ldt_info.entry_number;
279 if (ldt_info.base_addr == 0 && ldt_info.limit == 0 &&
286 ldt_info.useable = 0;
298 static long do_modify_ldt_skas(
int func,
void __user *ptr,
299 unsigned long bytecount)
305 ret = read_ldt(ptr, bytecount);
309 ret = write_ldt(ptr, bytecount, func);
312 ret = read_default_ldt(ptr, bytecount);
319 static short dummy_list[9] = {0, -1};
320 static short * host_ldt_entries =
NULL;
322 static void ldt_get_host_info(
void)
329 spin_lock(&host_ldt_lock);
331 if (host_ldt_entries !=
NULL) {
332 spin_unlock(&host_ldt_lock);
335 host_ldt_entries = dummy_list+1;
337 spin_unlock(&host_ldt_lock);
357 host_ldt_entries = dummy_list;
362 if (ldt[i].
a != 0 || ldt[i].
b != 0)
367 host_ldt_entries = dummy_list;
369 size = (size + 1) *
sizeof(dummy_list[0]);
376 host_ldt_entries =
tmp;
380 if (ldt[i].
a != 0 || ldt[i].
b != 0)
381 host_ldt_entries[k++] =
i;
383 host_ldt_entries[
k] = -1;
403 memset(&desc, 0,
sizeof(desc));
424 for (num_p=host_ldt_entries; *num_p != -1; num_p++) {
427 &addr, *(num_p + 1) == -1);
432 new_mm->
arch.ldt.entry_count = 0;
446 from_mm->
id.u.mm_fd } } );
448 if (i !=
sizeof(copy))
450 "failed, err = %d\n", -i);
461 if (from_mm->
arch.ldt.entry_count <= LDT_DIRECT_ENTRIES)
463 sizeof(new_mm->
arch.ldt.u.entries));
472 new_mm->
arch.ldt.u.pages[
i] =
478 new_mm->
arch.ldt.entry_count = from_mm->
arch.ldt.entry_count;
491 if (!ptrace_ldt && mm->
arch.ldt.entry_count > LDT_DIRECT_ENTRIES) {
496 mm->
arch.ldt.entry_count = 0;
501 return do_modify_ldt_skas(func, ptr, bytecount);