Commit graph

4 commits

Author SHA1 Message Date
Yabin Cui
3696a20b11 Revert "Revert "allow simpleperf to profile more app types.""
This reverts commit dd2079d7f0.

Bug: 199086135
Test: run simpleperf to record systemui.
Change-Id: Ibc6017d53a9835a2f8ff5409c825c0d70ef23e25
2021-10-27 11:05:01 -07:00
Yabin Cui
dd2079d7f0 Revert "allow simpleperf to profile more app types."
This reverts commit 26de4c4ecc.

Reason for revert: security concern

Bug: 199086135
Test: none
Change-Id: I0f3aa7f099121f350e487db4ef0135aa045911cb
2021-09-07 10:18:28 -07:00
Yabin Cui
26de4c4ecc allow simpleperf to profile more app types.
So simpleperf can profile these apps when they are marked to be
profileable/debuggable.

Bug: 192404394
Test: build and run simpleperf to profile com.android.systemui.
Change-Id: Ia2defe725a8fafbcb6c2d20e771b343d8822ccbc
2021-06-30 17:24:05 -07:00
Ryan Savitski
ffa0dd93f3 perf_event: rules for system and simpleperf domain
This patch adds the necessary rules to support the existing usage of
perf_event_open by the system partition, which almost exclusively
concerns the simpleperf profiler. A new domain is introduced for some
(but not all) executions of the system image simpleperf. The following
configurations are supported:
* shell -> shell process (no domain transition)
* shell -> debuggable app (through shell -> runas -> runas_app)
* shell -> profileable app (through shell -> simpleperf_app_runner ->
                            untrusted_app -> simpleperf)
* debuggable/profile app -> self (through untrusted_app -> simpleperf)

simpleperf_app_runner still enters the untrusted_app domain immediately
before exec to properly inherit the categories related to MLS. My
understanding is that a direct transition would require modifying
external/selinux and seapp_contexts as with "fromRunAs", which seems
unnecessarily complex for this case.

runas_app can still run side-loaded binaries and use perf_event_open,
but it checks that the target app is exactly "debuggable"
(profileability is insufficient).

system-wide profiling is effectively constrained to "su" on debug
builds.

See go/perf-event-open-security for a more detailed explanation of the
scenarios covered here.

Tested: "atest CtsSimpleperfTestCases" on crosshatch-user/userdebug
Tested: manual simpleperf invocations on crosshatch-userdebug
Bug: 137092007
Change-Id: I2100929bae6d81f336f72eff4235fd5a78b94066
2020-01-15 16:56:41 +00:00