diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 02:08:10 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 02:08:10 +0000 |
commit | e5856a7a015a8a4d790b51136881a32364ee912a (patch) | |
tree | c96a355ab2e2f663770f4c123244b28031a82b52 /sandbox/linux/suid/sandbox.c | |
parent | 8a0590e6696b0a6377cfc4cb71fa66beeef047d6 (diff) | |
download | chromium_src-e5856a7a015a8a4d790b51136881a32364ee912a.zip chromium_src-e5856a7a015a8a4d790b51136881a32364ee912a.tar.gz chromium_src-e5856a7a015a8a4d790b51136881a32364ee912a.tar.bz2 |
Linux: Adjust /proc/pid/oom_adj to sacrifice plugin and renderer processes to the OOM killer.
BUG=29752
TEST=During out of memory conditions, Linux kernel picks a plugin/renderer over the browser process.
Review URL: http://codereview.chromium.org/467058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34222 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/linux/suid/sandbox.c')
-rw-r--r-- | sandbox/linux/suid/sandbox.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sandbox/linux/suid/sandbox.c b/sandbox/linux/suid/sandbox.c index f54bcd1..04073d4 100644 --- a/sandbox/linux/suid/sandbox.c +++ b/sandbox/linux/suid/sandbox.c @@ -26,6 +26,7 @@ #include <unistd.h> #include "linux_util.h" +#include "process_util.h" #include "suid_unsafe_environment_variables.h" #if !defined(CLONE_NEWPID) @@ -309,7 +310,7 @@ int main(int argc, char **argv) { // when you call it with --find-inode INODE_NUMBER. if (argc == 3 && (0 == strcmp(argv[1], kFindInodeSwitch))) { pid_t pid; - char *endptr; + char* endptr; ino_t inode = strtoull(argv[2], &endptr, 10); if (inode == ULLONG_MAX || *endptr) return 1; @@ -318,6 +319,19 @@ int main(int argc, char **argv) { printf("%d\n", pid); return 0; } + // Likewise, we cannot adjust /proc/pid/oom_adj for sandboxed renderers + // because those files are owned by root. So we need another helper here. + if (argc == 4 && (0 == strcmp(argv[1], kAdjustOOMScoreSwitch))) { + char* endptr; + int score; + pid_t pid = strtoul(argv[2], &endptr, 10); + if (pid == ULONG_MAX || *endptr) + return 1; + score = strtol(argv[3], &endptr, 10); + if (score == LONG_MAX || score == LONG_MIN || *endptr) + return 1; + return AdjustOOMScore(pid, score); + } if (!MoveToNewPIDNamespace()) return 1; |