Allow to getattr kmsg_device

These denials occur on boot when android_get_control_file also
changes from readlink() to realpath(), because realpath() will
lstat() the given path.

Some other domains (fastbootd, update_engine, etc.) also uses
libcutils to write to kernel log, where android_get_control_file()
is invoked, hence getattr is added to them as well.

04-28 06:15:22.290   618   618 I auditd  : type=1400 audit(0.0:4): avc: denied { getattr } for comm="logd" path="/dev/kmsg" dev="tmpfs" ino=20917 scontext=u:r:logd:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
03-20 19:52:23.431   900   900 I auditd  : type=1400 audit(0.0:7): avc: denied { getattr } for comm="android.hardwar" path="/dev/kmsg" dev="tmpfs" ino=20917 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
...
03-20 22:40:42.316     1     1 W init    : type=1400 audit(0.0:33): avc: denied { getattr } for path="/dev/kmsg" dev="tmpfs" ino=21999 scontext=u:r:init:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0

Test: no denials related to these
Change-Id: I5263dd6b64c06fb092f3461858f57a1a09107429
This commit is contained in:
Yifan Hong 2019-03-20 15:36:26 -07:00
parent 37f5cb2db0
commit 5d89abde99
8 changed files with 8 additions and 8 deletions

View file

@ -16,7 +16,7 @@ recovery_only(`
allowxperm fastbootd functionfs:file ioctl { FUNCTIONFS_ENDPOINT_DESC };
# Log to serial
allow fastbootd kmsg_device:chr_file { open write };
allow fastbootd kmsg_device:chr_file { open getattr write };
# battery info
allow fastbootd sysfs_batteryinfo:file r_file_perms;

View file

@ -21,7 +21,7 @@ r_dir_file(hal_health_server, sysfs_batteryinfo)
wakelock_use(hal_health_server)
# Write to /dev/kmsg
allow hal_health_server kmsg_device:chr_file w_file_perms;
allow hal_health_server kmsg_device:chr_file { getattr w_file_perms };
# Allow to use timerfd to wake itself up periodically to send health info.
allow hal_health_server self:capability2 wake_alarm;

View file

@ -11,7 +11,7 @@ allow init tmpfs:chr_file { create setattr unlink rw_file_perms };
#
# /dev/kmsg
allow init tmpfs:chr_file relabelfrom;
allow init kmsg_device:chr_file { write relabelto };
allow init kmsg_device:chr_file { getattr write relabelto };
# /dev/kmsg_debug
userdebug_or_eng(`
allow init kmsg_debug_device:chr_file { write relabelto };

View file

@ -11,7 +11,7 @@ allow logd self:global_capability_class_set { setuid setgid setpcap sys_nice aud
allow logd self:global_capability2_class_set syslog;
allow logd self:netlink_audit_socket { create_socket_perms_no_ioctl nlmsg_write };
allow logd kernel:system syslog_read;
allow logd kmsg_device:chr_file w_file_perms;
allow logd kmsg_device:chr_file { getattr w_file_perms };
allow logd system_data_file:{ file lnk_file } r_file_perms;
allow logd pstorefs:dir search;
allow logd pstorefs:file r_file_perms;

View file

@ -13,7 +13,7 @@ allow update_engine self:global_capability_class_set { fowner sys_admin };
# denial.
dontaudit update_engine self:global_capability_class_set fsetid;
allow update_engine kmsg_device:chr_file w_file_perms;
allow update_engine kmsg_device:chr_file { getattr w_file_perms };
allow update_engine update_engine_exec:file rx_file_perms;
wakelock_use(update_engine);

View file

@ -22,7 +22,7 @@ allow update_verifier sysfs_dm:file r_file_perms;
allow update_verifier dm_device:blk_file r_file_perms;
# Write to kernel message.
allow update_verifier kmsg_device:chr_file w_file_perms;
allow update_verifier kmsg_device:chr_file { getattr w_file_perms };
# Allow update_verifier to reboot the device.
set_prop(update_verifier, powerctl_prop)

View file

@ -12,7 +12,7 @@ type vdc_exec, system_file_type, exec_type, file_type;
allow vdc devpts:chr_file rw_file_perms;
# vdc writes directly to kmsg during the boot process
allow vdc kmsg_device:chr_file w_file_perms;
allow vdc kmsg_device:chr_file { getattr w_file_perms };
# vdc talks to vold over Binder
binder_use(vdc)

View file

@ -5,7 +5,7 @@ type vendor_init, domain, mlstrustedsubject;
allow vendor_init init:unix_stream_socket { read write };
# Logging to kmsg
allow vendor_init kmsg_device:chr_file { open write };
allow vendor_init kmsg_device:chr_file { open getattr write };
# Mount on /dev/usb-ffs/adb.
allow vendor_init device:dir mounton;