aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/start_up.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/os-Linux/start_up.c')
-rw-r--r--arch/um/os-Linux/start_up.c77
1 files changed, 71 insertions, 6 deletions
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index b99ab414542f..37517d49c4ae 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
137int ptrace_faultinfo = 1; 137int ptrace_faultinfo = 1;
138int ptrace_ldt = 1;
138int proc_mm = 1; 139int proc_mm = 1;
140int skas_needs_stub = 0;
139 141
140static int __init skas0_cmd_param(char *str, int* add) 142static int __init skas0_cmd_param(char *str, int* add)
141{ 143{
@@ -294,7 +296,7 @@ static void __init check_ptrace(void)
294 check_sysemu(); 296 check_sysemu();
295} 297}
296 298
297extern int create_tmp_file(unsigned long len); 299extern int create_tmp_file(unsigned long long len);
298 300
299static void check_tmpexec(void) 301static void check_tmpexec(void)
300{ 302{
@@ -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
357static 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
356static inline void check_skas3_ptrace_support(void) 370static 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
384int can_do_skas(void) 398static 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
438static 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
453int 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