platform_system_core/rootdir
Ryan Savitski f0f7e70186 init: add builtin check for perf_event LSM hooks
Historically, the syscall was controlled by a system-wide
perf_event_paranoid sysctl, which is not flexible enough to allow only
specific processes to use the syscall. However, SELinux support for the
syscall has been upstreamed recently[1] (and is being backported to
Android R release common kernels).
[1] da97e18458

As the presence of these hooks is not guaranteed on all Android R
platforms (since we support upgrades while keeping an older kernel), we
need to test for the feature dynamically. The LSM hooks themselves have
no way of being detected directly, so we instead test for their effects,
so we perform several syscalls, and look for a specific success/failure
combination, corresponding to the platform's SELinux policy.

If hooks are detected, perf_event_paranoid is set to -1 (unrestricted),
as the SELinux policy is then sufficient to control access.

This is done within init for several reasons:
* CAP_SYS_ADMIN side-steps perf_event_paranoid, so the tests can be done
  if non-root users aren't allowed to use the syscall (the default).
* init is already the setter of the paranoid value (see init.rc), which
  is also a privileged operation.
* the test itself is simple (couple of syscalls), so having a dedicated
  test binary/domain felt excessive.

I decided to go through a new sysprop (set by a builtin test in
second-stage init), and keeping the actuation in init.rc. We can change
it to an immediate write to the paranoid value if a use-case comes up
that requires the decision to be made earlier in the init sequence.

Bug: 137092007
Change-Id: Ib13a31fee896f17a28910d993df57168a83a4b3d
2020-01-15 20:58:15 +00:00
..
avb Adding the AVB public key for Q-Developer-GSI 2019-12-10 13:02:31 +08:00
etc Use generated linker config only 2019-12-24 14:18:53 +09:00
adb_debug.prop Adding adb_debug.prop into debug ramdisk 2019-04-23 11:13:46 +08:00
Android.bp Move init and ueventd scripts from / to /system/etc 2019-11-08 10:15:49 -08:00
Android.mk Use generated linker config only 2019-12-24 14:18:53 +09:00
asan.options Include asan options from data partition. 2017-08-09 15:32:23 -07:00
asan_extract.rc Asan_extract: Use sys.powerctl 2017-04-19 18:32:27 -07:00
asan_extract.sh Asan_extract: Use sys.powerctl 2017-04-19 18:32:27 -07:00
init-debug.rc init-debug.rc: don't mount debugfs 2017-03-14 21:56:24 -07:00
init.environ.rc.in Rename ANDROID_RUNTIME_ROOT to ANDROID_ART_ROOT following APEX module name change. 2019-09-20 16:07:04 +01:00
init.rc init: add builtin check for perf_event LSM hooks 2020-01-15 20:58:15 +00:00
init.usb.configfs.rc Remove sys.usb.ffs.mtp.ready property 2018-03-22 11:35:20 -07:00
init.usb.rc Move setprop sys.usb.configfs 0 to on init action 2019-12-10 19:16:15 +00:00
init.zygote32.rc Remove references to /sys/android_power/* 2019-10-01 13:30:41 -07:00
init.zygote32_64.rc Remove references to /sys/android_power/* 2019-10-01 13:30:41 -07:00
init.zygote64.rc Remove references to /sys/android_power/* 2019-10-01 13:30:41 -07:00
init.zygote64_32.rc Remove references to /sys/android_power/* 2019-10-01 13:30:41 -07:00
OWNERS rootdir: add ccross to OWNERS. 2018-10-15 14:18:04 -07:00
ueventd.rc ueventd: duplicate /dev/ashmem 2019-09-25 12:49:38 -07:00