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, rootfs)
12
13# ueventd needs write access to files in /sys to regenerate uevents
14allow ueventd sysfs_type:file w_file_perms;
15r_dir_file(ueventd, sysfs_type)
16allow ueventd sysfs_type:{ file lnk_file } { relabelfrom relabelto setattr };
17allow ueventd sysfs_type:dir { relabelfrom relabelto setattr };
18allow ueventd tmpfs:chr_file rw_file_perms;
19allow ueventd dev_type:dir create_dir_perms;
20allow ueventd dev_type:lnk_file { create unlink };
21allow ueventd dev_type:chr_file { getattr create setattr unlink };
22allow ueventd dev_type:blk_file { getattr relabelfrom relabelto create setattr unlink };
23allow ueventd self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
24allow ueventd efs_file:dir search;
25allow ueventd efs_file:file r_file_perms;
26
27# Get SELinux enforcing status.
28r_dir_file(ueventd, selinuxfs)
29
30# Access for /vendor/ueventd.rc and /vendor/firmware
31r_dir_file(ueventd, { vendor_file_type -vendor_app_file -vendor_overlay_file })
32
33# Get file contexts for new device nodes
34allow ueventd file_contexts_file:file r_file_perms;
35
36# Use setfscreatecon() to label /dev directories and files.
37allow ueventd self:process setfscreate;
38
39#####
40##### neverallow rules
41#####
42
43# ueventd must never set properties, otherwise deadlocks may occur.
44# https://android-review.googlesource.com/#/c/133120/6/init/devices.cpp@941
45# No writing to the property socket, connecting to init, or setting properties.
46neverallow ueventd property_socket:sock_file write;
47neverallow ueventd init:unix_stream_socket connectto;
48neverallow ueventd property_type:property_service set;
49
50# Restrict ueventd access on block devices to maintenence operations.
51neverallow ueventd dev_type:blk_file ~{ getattr relabelfrom relabelto create setattr unlink };
52
53# Only relabelto as we would never want to relabelfrom kmem_device or port_device
54neverallow ueventd { kmem_device port_device }:chr_file ~{ getattr create setattr unlink relabelto };
55