Add use_bionic_libs macro

... to dedupe rules for allowing access to bootstrap bionic libraries.

Bug: N/A
Test: m
Change-Id: I575487416a356c22f5f06f1713032f11d979d7d4
This commit is contained in:
Jiyong Park 2022-01-23 23:55:41 +09:00
parent 40d41f7639
commit 16c1ae3a3d
17 changed files with 31 additions and 29 deletions

View file

@ -81,8 +81,7 @@ allow apexd apexd_exec:file execute_no_trans;
allow apexd rootfs:dir mounton;
# apexd is using bootstrap bionic
allow apexd system_bootstrap_lib_file:dir r_dir_perms;
allow apexd system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(apexd)
# Allow apexd to read file contexts when performing restorecon
allow apexd file_contexts_file:file r_file_perms;

View file

@ -4,8 +4,7 @@ type apkdmverity, domain, coredomain;
type apkdmverity_exec, exec_type, file_type, system_file_type;
# apkdmverity is using bootstrap bionic
allow apkdmverity system_bootstrap_lib_file:dir r_dir_perms;
allow apkdmverity system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(apkdmverity)
# apkdmverity accesses "payload metadata disk" which points to
# a /dev/vd* block device file.

View file

@ -17,5 +17,4 @@ add_service(diced, dice_maintenance_service)
selinux_check_access(diced)
# diced is using bootstrap bionic
allow diced system_bootstrap_lib_file:dir r_dir_perms;
allow diced system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(diced)

View file

@ -437,8 +437,7 @@ allow init system_data_file:lnk_file r_file_perms;
allow init proc_pressure_mem:file { rw_file_perms setattr };
# init is using bootstrap bionic
allow init system_bootstrap_lib_file:dir r_dir_perms;
allow init system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(init)
# stat the root dir of fuse filesystems (for the mount handler)
allow init fuse:dir { search getattr };

View file

@ -38,8 +38,7 @@ userdebug_or_eng(`
allow microdroid_manager self:vsock_socket { create_socket_perms_no_ioctl };
# microdroid_manager is using bootstrap bionic
allow microdroid_manager system_bootstrap_lib_file:dir r_dir_perms;
allow microdroid_manager system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(microdroid_manager)
# microdroid_manager can talk to diced over binder
binder_use(microdroid_manager)

View file

@ -27,5 +27,4 @@ add_service(servicemanager, service_manager_service)
set_prop(servicemanager, ctl_interface_start_prop)
# servicemanager is using bootstrap bionic
allow servicemanager system_bootstrap_lib_file:dir r_dir_perms;
allow servicemanager system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(servicemanager)

View file

@ -47,8 +47,7 @@ allow ueventd vendor_file:system module_load;
allow ueventd kernel:key search;
# ueventd is using bootstrap bionic
allow ueventd system_bootstrap_lib_file:dir r_dir_perms;
allow ueventd system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(ueventd)
# TODO(b/193118220): find out why this happens.
dontaudit ueventd tmpfs:chr_file { relabelfrom setattr };

View file

@ -7,8 +7,7 @@ type zipfuse, domain, coredomain;
type zipfuse_exec, exec_type, file_type, system_file_type;
# zipfuse is using bootstrap bionic
allow zipfuse system_bootstrap_lib_file:dir r_dir_perms;
allow zipfuse system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(zipfuse)
# allow basic rules to implement FUSE
allow zipfuse fuse_device:chr_file rw_file_perms;

View file

@ -987,3 +987,11 @@ define(`read_fstab', `
allow $1 gsi_public_metadata_file:file r_file_perms;
allow $1 proc_bootconfig:file r_file_perms;
')
######################################
# use_bootstrap_libs(domain)
# Allow domain to use bootstrap bionic libraries in system/lib[64]/bootstrap
define(`use_bootstrap_libs', `
allow $1 system_bootstrap_lib_file:dir r_dir_perms;
allow $1 system_bootstrap_lib_file:file { execute read open getattr map };
')

View file

@ -133,8 +133,7 @@ r_dir_file(vendor_init, vendor_file_type)
allow vendor_init self:global_capability_class_set sys_admin;
# vendor_init is using bootstrap bionic
allow vendor_init system_bootstrap_lib_file:dir r_dir_perms;
allow vendor_init system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(vendor_init)
# Get file context
allow vendor_init file_contexts_file:file r_file_perms;

View file

@ -5,5 +5,4 @@ type hal_dice_default_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(hal_dice_default)
# hal_dice_default is using bootstrap bionic
allow hal_dice_default system_bootstrap_lib_file:dir r_dir_perms;
allow hal_dice_default system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(hal_dice_default)

View file

@ -126,8 +126,7 @@ allow apexd vold_service:service_manager find;
binder_call(apexd, vold)
# apexd is using bootstrap bionic
allow apexd system_bootstrap_lib_file:dir r_dir_perms;
allow apexd system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(apexd)
# Allow apexd to be invoked with logwrapper from init during userspace reboot.
allow apexd devpts:chr_file { read write };

View file

@ -23,7 +23,7 @@ userdebug_or_eng(`
allow profcollectd vendor_file:dir r_dir_perms;
allow profcollectd vendor_kernel_modules:file r_file_perms;
# Allow profcollectd to read system bootstrap libs.
# Allow profcollectd to read (but not execute) system bootstrap libs.
allow profcollectd system_bootstrap_lib_file:dir search;
allow profcollectd system_bootstrap_lib_file:file r_file_perms;

View file

@ -609,8 +609,7 @@ allow init userspace_reboot_metadata_file:file w_file_perms;
allow init proc_pressure_mem:file { rw_file_perms setattr };
# init is using bootstrap bionic
allow init system_bootstrap_lib_file:dir r_dir_perms;
allow init system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(init)
# stat the root dir of fuse filesystems (for the mount handler)
allow init fuse:dir { search getattr };

View file

@ -1021,3 +1021,11 @@ define(`read_fstab', `
allow $1 gsi_public_metadata_file:file r_file_perms;
allow $1 proc_bootconfig:file r_file_perms;
')
######################################
# use_bootstrap_libs(domain)
# Allow domain to use bootstrap bionic libraries in system/lib[64]/bootstrap
define(`use_bootstrap_libs', `
allow $1 system_bootstrap_lib_file:dir r_dir_perms;
allow $1 system_bootstrap_lib_file:file { execute read open getattr map };
')

View file

@ -60,8 +60,7 @@ allow ueventd vendor_file:system module_load;
allow ueventd kernel:key search;
# ueventd is using bootstrap bionic
allow ueventd system_bootstrap_lib_file:dir r_dir_perms;
allow ueventd system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(ueventd)
# Allow ueventd to run shell scripts from vendor
allow ueventd vendor_shell_exec:file execute;

View file

@ -191,8 +191,7 @@ allow vendor_init self:global_capability_class_set sys_admin;
allow vendor_init misc_block_device:blk_file w_file_perms;
# vendor_init is using bootstrap bionic
allow vendor_init system_bootstrap_lib_file:dir r_dir_perms;
allow vendor_init system_bootstrap_lib_file:file { execute read open getattr map };
use_bootstrap_libs(vendor_init)
# allow filesystem tuning
allow vendor_init userdata_sysdev:file create_file_perms;