Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #include "library.h" | 1 #include "library.h" |
| 2 #include "sandbox_impl.h" | 2 #include "sandbox_impl.h" |
| 3 #include "syscall_table.h" | 3 #include "syscall_table.h" |
| 4 | 4 |
| 5 namespace playground { | 5 namespace playground { |
| 6 | 6 |
| 7 // Global variables | 7 // Global variables |
| 8 int Sandbox::proc_self_maps_ = -1; | 8 int Sandbox::proc_self_maps_ = -1; |
| 9 enum Sandbox::SandboxStatus Sandbox::status_ = STATUS_UNKNOWN; | 9 enum Sandbox::SandboxStatus Sandbox::status_ = STATUS_UNKNOWN; |
| 10 int Sandbox::pid_; | 10 int Sandbox::pid_; |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 library->makeWritable(true); | 467 library->makeWritable(true); |
| 468 library->patchSystemCalls(); | 468 library->patchSystemCalls(); |
| 469 library->makeWritable(false); | 469 library->makeWritable(false); |
| 470 break; | 470 break; |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 | 473 |
| 474 // Intercept system calls in libraries that are known to have them. | 474 // Intercept system calls in libraries that are known to have them. |
| 475 for (Maps::const_iterator iter = maps.begin(); iter != maps.end(); ++iter){ | 475 for (Maps::const_iterator iter = maps.begin(); iter != maps.end(); ++iter){ |
| 476 Library* library = *iter; | 476 Library* library = *iter; |
| 477 const char* mapping = iter.name().c_str(); | |
| 478 | |
| 479 // Find the actual base name of the mapped library by skipping past any | |
| 480 // SPC and forward-slashes. We don't want to accidentally find matches, | |
| 481 // because the directory name included part of our well-known lib names. | |
| 482 // | |
| 483 // Typically, prior to pruning, entries would look something like this: | |
| 484 // 08:01 2289011 /lib/libc-2.7.so | |
|
Markus (顧孟勤)
2010/02/24 01:43:08
Is this better? I hope this makes sense now.
agl
2010/02/24 01:58:16
Oh, yea. I just had the path in mind. Makes sense
Markus (顧孟勤)
2010/02/24 02:02:11
It's explicitly supposed to be able to deal with s
agl
2010/02/24 02:04:23
No I'm just a muppet. You should commit this befor
| |
| 485 for (const char *delim = " /"; *delim; ++delim) { | |
| 486 const char* skip = strrchr(mapping, *delim); | |
| 487 if (skip) { | |
| 488 mapping = skip + 1; | |
| 489 } | |
| 490 } | |
| 491 | |
| 477 for (const char **ptr = libs; *ptr; ptr++) { | 492 for (const char **ptr = libs; *ptr; ptr++) { |
| 478 const char *name = strstr(iter.name().c_str(), *ptr); | 493 const char *name = strstr(mapping, *ptr); |
| 479 if (name) { | 494 if (name == mapping) { |
| 480 char ch = name[strlen(*ptr)]; | 495 char ch = name[strlen(*ptr)]; |
| 481 if (ch < 'A' || (ch > 'Z' && ch < 'a') || ch > 'z') { | 496 if (ch < 'A' || (ch > 'Z' && ch < 'a') || ch > 'z') { |
| 482 if (library->parseElf()) { | 497 if (library->parseElf()) { |
| 483 library->makeWritable(true); | 498 library->makeWritable(true); |
| 484 library->patchSystemCalls(); | 499 library->patchSystemCalls(); |
| 485 library->makeWritable(false); | 500 library->makeWritable(false); |
| 486 break; | 501 break; |
| 487 } | 502 } |
| 488 } | 503 } |
| 489 } | 504 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 500 // Creating the trusted thread enables sandboxing | 515 // Creating the trusted thread enables sandboxing |
| 501 createTrustedThread(processFdPub_, cloneFdPub_, secureMem); | 516 createTrustedThread(processFdPub_, cloneFdPub_, secureMem); |
| 502 | 517 |
| 503 // We can no longer check for sandboxing support at this point, but we also | 518 // We can no longer check for sandboxing support at this point, but we also |
| 504 // know for a fact that it is available (as we just turned it on). So update | 519 // know for a fact that it is available (as we just turned it on). So update |
| 505 // the status to reflect this information. | 520 // the status to reflect this information. |
| 506 status_ = STATUS_ENABLED; | 521 status_ = STATUS_ENABLED; |
| 507 } | 522 } |
| 508 | 523 |
| 509 } // namespace | 524 } // namespace |
| OLD | NEW |