1# ueventd seclabel is specified in init.rc since
2# it lives in the rootfs and has no unique file type.
3type ueventd, domain;
4
5# Write to /dev/kmsg.
6allow ueventd kmsg_device:chr_file rw_file_perms;
7
8allow ueventd self:capability { chown mknod net_admin setgid fsetid sys_rawio dac_override fowner };
9allow ueventd device:file create_file_perms;
10
11r_dir_file(ueventd, sysfs_type)
12r_dir_file(ueventd, rootfs)
13allow ueventd sysfs:file w_file_perms;
14allow ueventd sysfs_usb:file w_file_perms;
15allow ueventd sysfs_hwrandom:file w_file_perms;
16allow ueventd sysfs_zram_uevent:file w_file_perms;
17allow ueventd sysfs_type:{ file lnk_file } { relabelfrom relabelto setattr getattr };
18allow ueventd sysfs_type:dir { relabelfrom relabelto setattr r_dir_perms };
19allow ueventd sysfs_devices_system_cpu:file rw_file_perms;
20allow ueventd tmpfs:chr_file rw_file_perms;
21allow ueventd dev_type:dir create_dir_perms;
22allow ueventd dev_type:lnk_file { create unlink };
23allow ueventd dev_type:chr_file { getattr create setattr unlink };
24allow ueventd dev_type:blk_file { getattr relabelfrom relabelto create setattr unlink };
25allow ueventd self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
26allow ueventd efs_file:dir search;
27allow ueventd efs_file:file r_file_perms;
28
29# Get SELinux enforcing status.
30r_dir_file(ueventd, selinuxfs)
31
32# Access for /vendor/ueventd.rc and /vendor/firmware
33r_dir_file(ueventd, vendor_file)
34
35# Get file contexts for new device nodes
36allow ueventd file_contexts_file:file r_file_perms;
37
38# Use setfscreatecon() to label /dev directories and files.
39allow ueventd self:process setfscreate;
40
41#####
42##### neverallow rules
43#####
44
45# ueventd must never set properties, otherwise deadlocks may occur.
46# https://android-review.googlesource.com/#/c/133120/6/init/devices.cpp@941
47# No writing to the property socket, connecting to init, or setting properties.
48neverallow ueventd property_socket:sock_file write;
49neverallow ueventd init:unix_stream_socket connectto;
50neverallow ueventd property_type:property_service set;
51
52# Restrict ueventd access on block devices to maintenence operations.
53neverallow ueventd dev_type:blk_file ~{ getattr relabelfrom relabelto create setattr unlink };
54
55# Only relabelto as we would never want to relabelfrom kmem_device or port_device
56neverallow ueventd { kmem_device port_device }:chr_file ~{ getattr create setattr unlink relabelto };
57