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

Issue 1384363002: [NOT TO COMMIT YET] Using proc/pid/status file contents to get process metrics in linux. (Closed)

Created:
5 years, 2 months ago by ssid
Modified:
4 years, 9 months ago
CC:
chromium-reviews, tracing+reviews_chromium.org, wfh+watch_chromium.org, rickyz (no longer on Chrome), picksi1
Base URL:
https://chromium.googlesource.com/chromium/src.git@smaps_fscan
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Using proc/pid/status file contents to get process metrics in linux. The sandboxed processes cannot read /proc directory to get the process metrics (working set size and peak) in linux. So, to work around this problem the browser sends the stats file data to renderer and the renderer needs to parse it. So, this CL adds api to process metrics to parse and get the metrics. BUG=461788

Patch Set 1 #

Patch Set 2 : Renames and fixes. #

Total comments: 12

Patch Set 3 : Change the api. #

Total comments: 1

Patch Set 4 : Remove the trace_event changes. #

Total comments: 11

Patch Set 5 : Fixes. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+65 lines, -24 lines) Patch
M base/process/process_metrics.h View 1 2 3 4 1 chunk +8 lines, -0 lines 0 comments Download
M base/process/process_metrics_linux.cc View 1 2 3 4 2 chunks +29 lines, -24 lines 0 comments Download
M base/process/process_metrics_unittest.cc View 1 2 3 4 1 chunk +28 lines, -0 lines 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 26 (9 generated)
ssid
+thestig I need to use the linux specific parsing code that exists in ProcessMetrics. But ...
5 years, 2 months ago (2015-10-06 09:39:52 UTC) #2
Lei Zhang
I'll take a look at this soon. +Linux sandboxing folks FYI
5 years, 2 months ago (2015-10-06 20:29:30 UTC) #9
ssid
On 2015/10/06 20:29:30, Lei Zhang wrote: > I'll take a look at this soon. > ...
5 years, 2 months ago (2015-10-06 20:50:13 UTC) #10
Lei Zhang
On 2015/10/06 20:50:13, ssid wrote: > On 2015/10/06 20:29:30, Lei Zhang wrote: > > I'll ...
5 years, 2 months ago (2015-10-06 20:57:07 UTC) #11
Lei Zhang
On 2015/10/06 20:57:07, Lei Zhang wrote: > How do you feel about merging this with ...
5 years, 2 months ago (2015-10-06 21:01:19 UTC) #12
ssid
On 2015/10/06 20:57:07, Lei Zhang wrote: > On 2015/10/06 20:50:13, ssid wrote: > > On ...
5 years, 2 months ago (2015-10-06 21:06:52 UTC) #13
ssid
On 2015/10/06 21:06:52, ssid wrote: > On 2015/10/06 20:57:07, Lei Zhang wrote: > > On ...
5 years, 2 months ago (2015-10-06 21:08:40 UTC) #14
Lei Zhang
https://codereview.chromium.org/1384363002/diff/140001/base/process/process_metrics_linux.cc File base/process/process_metrics_linux.cc (right): https://codereview.chromium.org/1384363002/diff/140001/base/process/process_metrics_linux.cc#newcode53 base/process/process_metrics_linux.cc:53: size_t ParseProcStatsAndGetFieldAsSizeT(const char* status_contents, Just use StringPiece instead of ...
5 years, 2 months ago (2015-10-06 21:09:00 UTC) #15
ssid
I have changed and moved the api. now calling it ParseProcStatus... Moved it along with ...
5 years, 2 months ago (2015-10-07 09:12:15 UTC) #16
Primiano Tucci (use gerrit)
Some general comments: - I'd not merge this with https://codereview.chromium.org/1329273002 as that one requires a ...
5 years, 2 months ago (2015-10-07 10:25:34 UTC) #18
ssid
On 2015/10/07 10:25:34, Primiano Tucci wrote: > Some general comments: > - I'd not merge ...
5 years, 2 months ago (2015-10-07 10:55:22 UTC) #19
ssid
I have removed the trace_event changes and just adding the api in this CL. Lets ...
5 years, 2 months ago (2015-10-07 11:00:41 UTC) #20
Lei Zhang
https://codereview.chromium.org/1384363002/diff/180001/base/process/process_metrics.h File base/process/process_metrics.h (right): https://codereview.chromium.org/1384363002/diff/180001/base/process/process_metrics.h#newcode313 base/process/process_metrics.h:313: BASE_EXPORT bool ParseProcStatusAndGetField( Why not #if defined(OS_LINUX) // and ...
5 years, 2 months ago (2015-10-07 16:10:54 UTC) #21
ssid
Thanks, PTAL https://codereview.chromium.org/1384363002/diff/180001/base/process/process_metrics.h File base/process/process_metrics.h (right): https://codereview.chromium.org/1384363002/diff/180001/base/process/process_metrics.h#newcode313 base/process/process_metrics.h:313: BASE_EXPORT bool ParseProcStatusAndGetField( On 2015/10/07 16:10:54, Lei ...
5 years, 2 months ago (2015-10-07 17:11:34 UTC) #23
Lei Zhang
The CL description needs to be updated. Otherwise LGTM. https://codereview.chromium.org/1384363002/diff/180001/base/process/process_metrics.h File base/process/process_metrics.h (right): https://codereview.chromium.org/1384363002/diff/180001/base/process/process_metrics.h#newcode313 base/process/process_metrics.h:313: ...
5 years, 2 months ago (2015-10-08 06:31:30 UTC) #24
jln (very slow on Chromium)
When you add the actual IPC, please make sure that you restrict which field of ...
5 years, 2 months ago (2015-10-19 19:18:43 UTC) #25
Primiano Tucci (use gerrit)
5 years, 1 month ago (2015-10-29 19:03:30 UTC) #26
On 2015/10/19 19:18:43, jln (slow on Chromium) wrote:
> When you add the actual IPC, please make sure that you restrict which field of
> "status" you allow to access. A lot of these fields are technically info leaks
> (in an ideal world, renderers wouldn't even know their own "external pid" and
> we're slowly moving towards that).
> 
> Also of course, there is no telling how this file will evolve over time and
what
> info it'll contain: so let's have a (hopefully small) whitelist of fields.

We had an internal discussion and I think we are going to make simpler and at
the same time stronger from the security viewpoint.
The plan is that this data will never reach back the renderer (no IPC at all).
The way it's going to work is that the browser process is going to create the
memory dumps and add to the (browser process) trace annotating this with a "this
is really for the renderer X), so all the data will stay in the browser.

I think this CL still applies though, for the following reason:
On Linux desktop, the browser can open directly /proc/PID_OF_RENDERER/status and
friends with no problem.
On Android it cannot, as renderers have a separate uid namespace (due to the
isolated_process label).
Right now each renderer can open its own /proc/self/status and everything is
fine.
But once Android seccomp-bpf will be on, this should be changes as follows:
 renderers are going to hand to the browser the fd to their own
/proc/self/status, and the browser will open and parse it.
But at that point there should be no problem for the browser to access arbitrary
fields in /proc/.../status for the renderers, as they will be consumed only in
the browser.

Does it make sense?

Powered by Google App Engine
This is Rietveld 408576698