Skip to content

Commit 8f6b03c

Browse files
committed
sepolicy support for cgroup v2
cgroup v2 is going to be used for freezer v2 support. The cgroup v2 hiearchy will be mounted by init under /sys/fs/cgroup hence proper access rights are necessary for sysfs. After mounting, the cgroup v2 kernfs will use the label cgroup_v2 and system_manager will handle the freezer Bug: 154548692 Test: verified that the freezer works as expected after applying this patch Change-Id: Idfb3f6e77b60dad032d1e306d2f9b58cd5775960 Merged-In: Idfb3f6e77b60dad032d1e306d2f9b58cd5775960
1 parent 202b346 commit 8f6b03c

File tree

14 files changed

+18
-10
lines changed

14 files changed

+18
-10
lines changed

prebuilts/api/30.0/private/compat/29.0/29.0.cil

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
;; types removed from current policy
22
(type ashmemd)
3+
(type cgroup_bpf)
34
(type hal_wifi_offload_hwservice)
45
(type install_recovery)
56
(type install_recovery_exec)

prebuilts/api/30.0/private/compat/29.0/29.0.ignore.cil

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
boringssl_self_test
3030
bq_config_prop
3131
cacheinfo_service
32+
cgroup_v2
3233
charger_prop
3334
cold_boot_done_prop
3435
credstore

prebuilts/api/30.0/private/genfs_contexts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ genfscon fusectl / u:object_r:fusectlfs:s0
103103
# selinuxfs booleans can be individually labeled.
104104
genfscon selinuxfs / u:object_r:selinuxfs:s0
105105
genfscon cgroup / u:object_r:cgroup:s0
106-
genfscon cgroup2 / u:object_r:cgroup_bpf:s0
106+
genfscon cgroup2 / u:object_r:cgroup_v2:s0
107107
# sysfs labels can be set by userspace.
108108
genfscon sysfs / u:object_r:sysfs:s0
109109
genfscon sysfs /devices/system/cpu u:object_r:sysfs_devices_system_cpu:s0

prebuilts/api/30.0/private/system_server.te

+2
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,8 @@ allow system_server preloads_media_file:dir { r_dir_perms write remove_name rmdi
893893

894894
r_dir_file(system_server, cgroup)
895895
allow system_server ion_device:chr_file r_file_perms;
896+
allow system_server cgroup_v2:dir r_dir_perms;
897+
allow system_server cgroup_v2:file rw_file_perms;
896898

897899
r_dir_file(system_server, proc_asound)
898900
r_dir_file(system_server, proc_net_type)

prebuilts/api/30.0/public/file.te

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type proc_zoneinfo, fs_type, proc_type;
7777
type selinuxfs, fs_type, mlstrustedobject;
7878
type fusectlfs, fs_type;
7979
type cgroup, fs_type, mlstrustedobject;
80-
type cgroup_bpf, fs_type;
80+
type cgroup_v2, fs_type;
8181
type sysfs, fs_type, sysfs_type, mlstrustedobject;
8282
type sysfs_android_usb, fs_type, sysfs_type;
8383
type sysfs_uio, sysfs_type, fs_type;
@@ -523,7 +523,7 @@ type vndservice_contexts_file, file_type;
523523
# Allow files to be created in their appropriate filesystems.
524524
allow fs_type self:filesystem associate;
525525
allow cgroup tmpfs:filesystem associate;
526-
allow cgroup_bpf tmpfs:filesystem associate;
526+
allow cgroup_v2 tmpfs:filesystem associate;
527527
allow cgroup_rc_file tmpfs:filesystem associate;
528528
allow sysfs_type sysfs:filesystem associate;
529529
allow debugfs_type { debugfs debugfs_tracing debugfs_tracing_debug }:filesystem associate;

prebuilts/api/30.0/public/init.te

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ allow init {
9696
postinstall_mnt_dir
9797
mirror_data_file
9898
}:dir mounton;
99-
allow init cgroup_bpf:dir { create mounton };
99+
allow init cgroup_v2:dir { mounton create_dir_perms };
100100

101101
# Mount bpf fs on sys/fs/bpf
102102
allow init fs_bpf:dir mounton;

prebuilts/api/30.0/public/netd.te

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ allow netd sysfs_net:file w_file_perms;
6060
# TODO: added to match above sysfs rule. Remove me?
6161
allow netd sysfs_usb:file write;
6262

63-
r_dir_file(netd, cgroup_bpf)
63+
r_dir_file(netd, cgroup_v2)
6464

6565
allow netd fs_bpf:dir search;
6666
allow netd fs_bpf:file { read write };

private/compat/29.0/29.0.cil

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
;; types removed from current policy
22
(type ashmemd)
3+
(type cgroup_bpf)
34
(type hal_wifi_offload_hwservice)
45
(type install_recovery)
56
(type install_recovery_exec)

private/compat/29.0/29.0.ignore.cil

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
boringssl_self_test
3030
bq_config_prop
3131
cacheinfo_service
32+
cgroup_v2
3233
charger_prop
3334
cold_boot_done_prop
3435
credstore

private/genfs_contexts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ genfscon fusectl / u:object_r:fusectlfs:s0
103103
# selinuxfs booleans can be individually labeled.
104104
genfscon selinuxfs / u:object_r:selinuxfs:s0
105105
genfscon cgroup / u:object_r:cgroup:s0
106-
genfscon cgroup2 / u:object_r:cgroup_bpf:s0
106+
genfscon cgroup2 / u:object_r:cgroup_v2:s0
107107
# sysfs labels can be set by userspace.
108108
genfscon sysfs / u:object_r:sysfs:s0
109109
genfscon sysfs /devices/system/cpu u:object_r:sysfs_devices_system_cpu:s0

private/system_server.te

+2
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,8 @@ allow system_server preloads_media_file:dir { r_dir_perms write remove_name rmdi
893893

894894
r_dir_file(system_server, cgroup)
895895
allow system_server ion_device:chr_file r_file_perms;
896+
allow system_server cgroup_v2:dir r_dir_perms;
897+
allow system_server cgroup_v2:file rw_file_perms;
896898

897899
r_dir_file(system_server, proc_asound)
898900
r_dir_file(system_server, proc_net_type)

public/file.te

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type proc_zoneinfo, fs_type, proc_type;
7777
type selinuxfs, fs_type, mlstrustedobject;
7878
type fusectlfs, fs_type;
7979
type cgroup, fs_type, mlstrustedobject;
80-
type cgroup_bpf, fs_type;
80+
type cgroup_v2, fs_type;
8181
type sysfs, fs_type, sysfs_type, mlstrustedobject;
8282
type sysfs_android_usb, fs_type, sysfs_type;
8383
type sysfs_uio, sysfs_type, fs_type;
@@ -523,7 +523,7 @@ type vndservice_contexts_file, file_type;
523523
# Allow files to be created in their appropriate filesystems.
524524
allow fs_type self:filesystem associate;
525525
allow cgroup tmpfs:filesystem associate;
526-
allow cgroup_bpf tmpfs:filesystem associate;
526+
allow cgroup_v2 tmpfs:filesystem associate;
527527
allow cgroup_rc_file tmpfs:filesystem associate;
528528
allow sysfs_type sysfs:filesystem associate;
529529
allow debugfs_type { debugfs debugfs_tracing debugfs_tracing_debug }:filesystem associate;

public/init.te

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ allow init {
9696
postinstall_mnt_dir
9797
mirror_data_file
9898
}:dir mounton;
99-
allow init cgroup_bpf:dir { create mounton };
99+
allow init cgroup_v2:dir { mounton create_dir_perms };
100100

101101
# Mount bpf fs on sys/fs/bpf
102102
allow init fs_bpf:dir mounton;

public/netd.te

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ allow netd sysfs_net:file w_file_perms;
6060
# TODO: added to match above sysfs rule. Remove me?
6161
allow netd sysfs_usb:file write;
6262

63-
r_dir_file(netd, cgroup_bpf)
63+
r_dir_file(netd, cgroup_v2)
6464

6565
allow netd fs_bpf:dir search;
6666
allow netd fs_bpf:file { read write };

0 commit comments

Comments
 (0)