|
Before this change, we only trigger GC and sleep 5 seconds, hoping that
processes in chroot exit within that 5 seconds.
After this change, we use pidfd to wait for processes to exit, so
teardown can be performed as soon as all processes have exited, making
teardown considerably faster.
Also, if the processes don't exit within 5 seconds, we kill them, making
teardown more reliable.
Only one more SELinux permission is needed, which is the permission to
send `sigkill` to artd and its subprocesses. system_server already has
all the other permissions to perform the operations used in this CL.
1. system_server has supplementary group "readproc" (3009), to list all
pids in "/proc", bypassing "hidepid=2" (see proc(5)).
- https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/com/android/internal/os/ZygoteInit.java;l=658;drc=7d3ffbae618e9e728644a96647ed709bf39ae759
2. system_server can read /proc/<pid>/* for all domains.
- https://cs.android.com/android/platform/superproject/main/+/main:system/sepolicy/private/system_server.te;l=213;drc=ca2f3851afaee866d37caae16598b3d5c20844d4
3. system_server has CAP_SYS_PTRACE, to read the "/proc/<pid>/exe" link
of anyprocess (see proc(5)).
- https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/com/android/internal/os/ZygoteInit.java;l=635;drc=7d3ffbae618e9e728644a96647ed709bf39ae759
- https://cs.android.com/android/platform/superproject/main/+/main:system/sepolicy/private/system_server.te;l=145;drc=ca2f3851afaee866d37caae16598b3d5c20844d4
4. system_server has CAP_KILL, to kill processes that belong to other
users (see kill(2)).
- https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/com/android/internal/os/ZygoteInit.java;l=628;drc=7d3ffbae618e9e728644a96647ed709bf39ae759
- https://cs.android.com/android/platform/superproject/main/+/main:system/sepolicy/private/system_server.te;l=138;drc=ca2f3851afaee866d37caae16598b3d5c20844d4
Bug: 311377497
Test: m test-art-host-gtest-art_libarttools_tests
Test: atest art_standalone_libarttools_tests --iterations 10
Test: adb shell pm art pr-dexopt-job --test
Test: Run and cancel Pre-reboot Dexopt multiple times.
Change-Id: I1e41cd71402944e31b33e410ac1635766afe55c4
|