diff options
author | Bodo Stroesser <bstroesser@fujitsu-siemens.com> | 2005-11-07 03:58:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-07 10:53:31 -0500 |
commit | 858259cf7d1c443c836a2022b78cb281f0a9b95e (patch) | |
tree | 7d306450dd0dfa907bbee1d95f96191c67f74232 /arch/um/os-Linux/start_up.c | |
parent | e763b793f7e5c09a859fc420eb0de385d80cf636 (diff) |
[PATCH] uml: maintain own LDT entries
Patch imlements full LDT handling in SKAS:
* UML holds it's own LDT table, used to deliver data on
modify_ldt(READ)
* UML disables the default_ldt, inherited from the host (SKAS3)
or resets LDT entries, set by host's clib and inherited in
SKAS0
* A new global variable skas_needs_stub is inserted, that
can be used to decide, whether stub-pages must be supported
or not.
* Uses the syscall-stub to replace missing PTRACE_LDT (therefore,
write_ldt_entry needs to be modified)
Signed-off-by: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux/start_up.c')
-rw-r--r-- | arch/um/os-Linux/start_up.c | 75 |
1 files changed, 70 insertions, 5 deletions
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index b99ab414542f..553a09c7d0bc 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c | |||
@@ -135,7 +135,9 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode, | |||
135 | } | 135 | } |
136 | 136 | ||
137 | int ptrace_faultinfo = 1; | 137 | int ptrace_faultinfo = 1; |
138 | int ptrace_ldt = 1; | ||
138 | int proc_mm = 1; | 139 | int proc_mm = 1; |
140 | int skas_needs_stub = 0; | ||
139 | 141 | ||
140 | static int __init skas0_cmd_param(char *str, int* add) | 142 | static int __init skas0_cmd_param(char *str, int* add) |
141 | { | 143 | { |
@@ -352,14 +354,26 @@ __uml_setup("noptracefaultinfo", noptracefaultinfo_cmd_param, | |||
352 | " it. To support PTRACE_FAULTINFO, the host needs to be patched\n" | 354 | " it. To support PTRACE_FAULTINFO, the host needs to be patched\n" |
353 | " using the current skas3 patch.\n\n"); | 355 | " using the current skas3 patch.\n\n"); |
354 | 356 | ||
357 | static int __init noptraceldt_cmd_param(char *str, int* add) | ||
358 | { | ||
359 | ptrace_ldt = 0; | ||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | __uml_setup("noptraceldt", noptraceldt_cmd_param, | ||
364 | "noptraceldt\n" | ||
365 | " Turns off usage of PTRACE_LDT, even if host supports it.\n" | ||
366 | " To support PTRACE_LDT, the host needs to be patched using\n" | ||
367 | " the current skas3 patch.\n\n"); | ||
368 | |||
355 | #ifdef UML_CONFIG_MODE_SKAS | 369 | #ifdef UML_CONFIG_MODE_SKAS |
356 | static inline void check_skas3_ptrace_support(void) | 370 | static inline void check_skas3_ptrace_faultinfo(void) |
357 | { | 371 | { |
358 | struct ptrace_faultinfo fi; | 372 | struct ptrace_faultinfo fi; |
359 | void *stack; | 373 | void *stack; |
360 | int pid, n; | 374 | int pid, n; |
361 | 375 | ||
362 | printf("Checking for the skas3 patch in the host..."); | 376 | printf(" - PTRACE_FAULTINFO..."); |
363 | pid = start_ptraced_child(&stack); | 377 | pid = start_ptraced_child(&stack); |
364 | 378 | ||
365 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); | 379 | n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); |
@@ -381,9 +395,49 @@ static inline void check_skas3_ptrace_support(void) | |||
381 | stop_ptraced_child(pid, stack, 1, 1); | 395 | stop_ptraced_child(pid, stack, 1, 1); |
382 | } | 396 | } |
383 | 397 | ||
384 | int can_do_skas(void) | 398 | static inline void check_skas3_ptrace_ldt(void) |
399 | { | ||
400 | #ifdef PTRACE_LDT | ||
401 | void *stack; | ||
402 | int pid, n; | ||
403 | unsigned char ldtbuf[40]; | ||
404 | struct ptrace_ldt ldt_op = (struct ptrace_ldt) { | ||
405 | .func = 2, /* read default ldt */ | ||
406 | .ptr = ldtbuf, | ||
407 | .bytecount = sizeof(ldtbuf)}; | ||
408 | |||
409 | printf(" - PTRACE_LDT..."); | ||
410 | pid = start_ptraced_child(&stack); | ||
411 | |||
412 | n = ptrace(PTRACE_LDT, pid, 0, (unsigned long) &ldt_op); | ||
413 | if (n < 0) { | ||
414 | if(errno == EIO) | ||
415 | printf("not found\n"); | ||
416 | else { | ||
417 | perror("not found"); | ||
418 | } | ||
419 | ptrace_ldt = 0; | ||
420 | } | ||
421 | else { | ||
422 | if(ptrace_ldt) | ||
423 | printf("found\n"); | ||
424 | else | ||
425 | printf("found, but use is disabled\n"); | ||
426 | } | ||
427 | |||
428 | stop_ptraced_child(pid, stack, 1, 1); | ||
429 | #else | ||
430 | /* PTRACE_LDT might be disabled via cmdline option. | ||
431 | * We want to override this, else we might use the stub | ||
432 | * without real need | ||
433 | */ | ||
434 | ptrace_ldt = 1; | ||
435 | #endif | ||
436 | } | ||
437 | |||
438 | static inline void check_skas3_proc_mm(void) | ||
385 | { | 439 | { |
386 | printf("Checking for /proc/mm..."); | 440 | printf(" - /proc/mm..."); |
387 | if (os_access("/proc/mm", OS_ACC_W_OK) < 0) { | 441 | if (os_access("/proc/mm", OS_ACC_W_OK) < 0) { |
388 | proc_mm = 0; | 442 | proc_mm = 0; |
389 | printf("not found\n"); | 443 | printf("not found\n"); |
@@ -394,8 +448,19 @@ int can_do_skas(void) | |||
394 | else | 448 | else |
395 | printf("found\n"); | 449 | printf("found\n"); |
396 | } | 450 | } |
451 | } | ||
452 | |||
453 | int can_do_skas(void) | ||
454 | { | ||
455 | printf("Checking for the skas3 patch in the host:\n"); | ||
456 | |||
457 | check_skas3_proc_mm(); | ||
458 | check_skas3_ptrace_faultinfo(); | ||
459 | check_skas3_ptrace_ldt(); | ||
460 | |||
461 | if(!proc_mm || !ptrace_faultinfo || !ptrace_ldt) | ||
462 | skas_needs_stub = 1; | ||
397 | 463 | ||
398 | check_skas3_ptrace_support(); | ||
399 | return 1; | 464 | return 1; |
400 | } | 465 | } |
401 | #else | 466 | #else |