Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Unified Diff: sandbox/linux/suid/sandbox.c

Issue 467058: Linux: Adjust /proc/pid/oom_adj to sacrifice plugin and renderer processes to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sandbox/linux/suid/sandbox.c
===================================================================
--- sandbox/linux/suid/sandbox.c (revision 34180)
+++ sandbox/linux/suid/sandbox.c (working copy)
@@ -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 @@
// 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 @@
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;

Powered by Google App Engine
This is Rietveld 408576698