summaryrefslogtreecommitdiffstats
path: root/chrome/browser/memory_details_linux.cc
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-09 21:25:19 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-09 21:25:19 +0000
commit21fc8e76330cca8eaca830bd1f3f8ee0e8889e1b (patch)
tree9b69d8d09baf638ed778b0a3c0fdf0520266037d /chrome/browser/memory_details_linux.cc
parent4717d1f7a2507e73ffd87fc42c47a7d163e30301 (diff)
downloadchromium_src-21fc8e76330cca8eaca830bd1f3f8ee0e8889e1b.zip
chromium_src-21fc8e76330cca8eaca830bd1f3f8ee0e8889e1b.tar.gz
chromium_src-21fc8e76330cca8eaca830bd1f3f8ee0e8889e1b.tar.bz2
Linux: Fix about:memory for SUID sandbox + pid namespaces.
BUG=36934 TEST=about:memory works on Linux machines with pid namespaces enabled. Review URL: http://codereview.chromium.org/752001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/memory_details_linux.cc')
-rw-r--r--chrome/browser/memory_details_linux.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/chrome/browser/memory_details_linux.cc b/chrome/browser/memory_details_linux.cc
index e7780bf..0c15671 100644
--- a/chrome/browser/memory_details_linux.cc
+++ b/chrome/browser/memory_details_linux.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/child_process_host.h"
#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/zygote_host_linux.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/url_constants.h"
#include "grit/chromium_strings.h"
@@ -163,17 +164,25 @@ static void GetProcessDataMemoryInformation(
// Find all children of the given process.
static void GetAllChildren(const std::vector<Process>& processes,
- pid_t root, std::vector<pid_t>* out) {
+ const pid_t root, const pid_t zygote,
+ std::vector<pid_t>* out) {
out->clear();
out->push_back(root);
std::set<pid_t> wavefront, next_wavefront;
wavefront.insert(root);
+ bool zygote_found = zygote ? false : true;
while (wavefront.size()) {
for (std::vector<Process>::const_iterator
i = processes.begin(); i != processes.end(); ++i) {
- if (wavefront.count(i->parent)) {
+ // Handle the zygote separately. With the SUID sandbox and a separate
+ // pid namespace, the zygote's parent process is not the browser.
+ if (!zygote_found && zygote == i->pid) {
+ zygote_found = true;
+ out->push_back(i->pid);
+ next_wavefront.insert(i->pid);
+ } else if (wavefront.count(i->parent)) {
out->push_back(i->pid);
next_wavefront.insert(i->pid);
}
@@ -221,7 +230,8 @@ void MemoryDetails::CollectProcessData(
}
std::vector<pid_t> current_browser_processes;
- GetAllChildren(processes, getpid(), &current_browser_processes);
+ const pid_t zygote = Singleton<ZygoteHost>()->pid();
+ GetAllChildren(processes, getpid(), zygote, &current_browser_processes);
ProcessData current_browser;
GetProcessDataMemoryInformation(current_browser_processes, &current_browser);
current_browser.name = chrome::kBrowserAppName;
@@ -233,7 +243,7 @@ void MemoryDetails::CollectProcessData(
for (std::set<pid_t>::const_iterator
i = browsers_found.begin(); i != browsers_found.end(); ++i) {
std::vector<pid_t> browser_processes;
- GetAllChildren(processes, *i, &browser_processes);
+ GetAllChildren(processes, *i, 0, &browser_processes);
ProcessData browser;
GetProcessDataMemoryInformation(browser_processes, &browser);