ueventd.te 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # ueventd seclabel is specified in init.rc since
  2. # it lives in the rootfs and has no unique file type.
  3. type ueventd, domain;
  4. type ueventd_tmpfs, file_type;
  5. # Write to /dev/kmsg.
  6. allow ueventd kmsg_device:chr_file rw_file_perms;
  7. allow ueventd self:global_capability_class_set { chown mknod net_admin setgid fsetid sys_rawio dac_override dac_read_search fowner };
  8. allow ueventd device:file create_file_perms;
  9. r_dir_file(ueventd, rootfs)
  10. # ueventd needs write access to files in /sys to regenerate uevents
  11. allow ueventd sysfs_type:file w_file_perms;
  12. r_dir_file(ueventd, sysfs_type)
  13. allow ueventd sysfs_type:{ file lnk_file } { relabelfrom relabelto setattr };
  14. allow ueventd sysfs_type:dir { relabelfrom relabelto setattr };
  15. allow ueventd tmpfs:chr_file rw_file_perms;
  16. allow ueventd dev_type:dir create_dir_perms;
  17. allow ueventd dev_type:lnk_file { create unlink };
  18. allow ueventd dev_type:chr_file { getattr create setattr unlink };
  19. allow ueventd dev_type:blk_file { getattr relabelfrom relabelto create setattr unlink };
  20. allow ueventd self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
  21. allow ueventd efs_file:dir search;
  22. allow ueventd efs_file:file r_file_perms;
  23. # Get SELinux enforcing status.
  24. r_dir_file(ueventd, selinuxfs)
  25. # Access for /vendor/ueventd.rc and /vendor/firmware
  26. r_dir_file(ueventd, { vendor_file_type -vendor_app_file -vendor_overlay_file })
  27. # Get file contexts for new device nodes
  28. allow ueventd file_contexts_file:file r_file_perms;
  29. # Use setfscreatecon() to label /dev directories and files.
  30. allow ueventd self:process setfscreate;
  31. # Allow ueventd to read androidboot.android_dt_dir from kernel cmdline.
  32. allow ueventd proc_cmdline:file r_file_perms;
  33. # Everything is labeled as rootfs in recovery mode. ueventd has to execute
  34. # the dynamic linker and shared libraries.
  35. recovery_only(`
  36. allow ueventd rootfs:file { r_file_perms execute };
  37. ')
  38. # Suppress denials for ueventd to getattr /postinstall. This occurs when the
  39. # linker tries to resolve paths in ld.config.txt.
  40. dontaudit ueventd postinstall_mnt_dir:dir getattr;
  41. # ueventd loads modules in response to modalias events.
  42. allow ueventd self:global_capability_class_set sys_module;
  43. allow ueventd vendor_file:system module_load;
  44. allow ueventd kernel:key search;
  45. # ueventd is using bootstrap bionic
  46. allow ueventd system_bootstrap_lib_file:dir r_dir_perms;
  47. allow ueventd system_bootstrap_lib_file:file { execute read open getattr map };
  48. #####
  49. ##### neverallow rules
  50. #####
  51. # ueventd must never set properties, otherwise deadlocks may occur.
  52. # https://android-review.googlesource.com/#/c/133120/6/init/devices.cpp@941
  53. # No writing to the property socket, connecting to init, or setting properties.
  54. neverallow ueventd property_socket:sock_file write;
  55. neverallow ueventd init:unix_stream_socket connectto;
  56. neverallow ueventd property_type:property_service set;
  57. # Restrict ueventd access on block devices to maintenence operations.
  58. neverallow ueventd dev_type:blk_file ~{ getattr relabelfrom relabelto create setattr unlink };
  59. # Only relabelto as we would never want to relabelfrom port_device
  60. neverallow ueventd port_device:chr_file ~{ getattr create setattr unlink relabelto };
  61. # Nobody should be able to ptrace ueventd
  62. neverallow * ueventd:process ptrace;