Allow kernel to write to shell_data_file loop devices in userdebug builds.

Tests around Virtual A/B, DSUs, remount etc need to create loop devices
and write to them, which requires the kernel domain to have file write
access.  However there are very few contexts where this is allowed, and
most are for testing. These testing locations are not consistently
available (eg, /data/nativetest does not always exist).

We already allow readonly loop devices in /data/local/tmp for testing
purposes, so this adds write support as well (userdebug/eng only).

Bug: 218976943
Test: fiemap_image_test
Change-Id: Ic83ff5ef57241215240228ecaee3d9d07ff31d8e
This commit is contained in:
David Anderson 2022-07-20 11:20:04 -07:00
parent d5098f99a9
commit 568fd1f0ad

View file

@ -95,10 +95,10 @@ allow kernel {
staging_data_file
vendor_apex_file
}:file read;
# Also allow the kernel to read /data/local/tmp files via loop device
# for ApexTestCases
# Also allow the kernel to read/write /data/local/tmp files via loop device
# for ApexTestCases and fiemap_image_test.
userdebug_or_eng(`
allow kernel shell_data_file:file read;
allow kernel shell_data_file:file { read write };
')
# Allow the first-stage init (which is running in the kernel domain) to execute the