Skip to content
Snippets Groups Projects
  • Nick Kralevich's avatar
    Get rid of auditallow spam. · 79a08e13
    Nick Kralevich authored
    Fixes the following SELinux messages when running adb bugreport:
    
    avc: granted { read } for name="libart.so" dev="dm-0" ino=1886
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:libart_file:s0 tclass=file
    
    avc: granted { read open } for path="/system/lib64/libart.so" dev="dm-0"
    ino=1886 scontext=u:r:dumpstate:s0 tcontext=u:object_r:libart_file:s0
    tclass=file
    
    avc: granted { getattr } for path="/system/lib64/libart.so" dev="dm-0"
    ino=1886 scontext=u:r:dumpstate:s0 tcontext=u:object_r:libart_file:s0
    tclass=file
    
    avc: granted { read } for path="/system/lib64/libart.so" dev="dm-0"
    ino=1886 scontext=u:r:dumpstate:s0 tcontext=u:object_r:libart_file:s0
    tclass=file
    
    avc: granted { read } for path="/system/lib64/libart.so" dev="dm-0"
    ino=1886 scontext=u:r:dumpstate:s0 tcontext=u:object_r:libart_file:s0
    tclass=file
    
    avc: granted { read } for path="/system/lib64/libart.so" dev="dm-0"
    ino=1886 scontext=u:r:dumpstate:s0 tcontext=u:object_r:libart_file:s0
    tclass=file
    
    avc: granted { read } for path="/system/lib64/libart.so" dev="dm-0"
    ino=1886 scontext=u:r:dumpstate:s0 tcontext=u:object_r:libart_file:s0
    tclass=file
    
    avc: granted { read execute } for path="/system/lib64/libart.so"
    dev="dm-0" ino=1886 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:libart_file:s0 tclass=file
    
    avc: granted { read } for path="/system/lib64/libart.so" dev="dm-0"
    ino=1886 scontext=u:r:dumpstate:s0 tcontext=u:object_r:libart_file:s0
    tclass=file
    
    avc: granted { read } for path="/system/lib64/libart.so" dev="dm-0"
    ino=1886 scontext=u:r:dumpstate:s0 tcontext=u:object_r:libart_file:s0
    tclass=file
    
    avc: granted { search } for name="dalvik-cache" dev="dm-2" ino=106289
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:dalvikcache_data_file:s0
    tclass=dir
    
    avc: granted { getattr } for path="/data/dalvik-cache/arm64" dev="dm-2"
    ino=106290 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:dalvikcache_data_file:s0 tclass=dir
    
    avc: granted { search } for name="dalvik-cache" dev="dm-2" ino=106289
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:dalvikcache_data_file:s0
    tclass=dir
    
    avc: granted { search } for name="arm64" dev="dm-2" ino=106290
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:dalvikcache_data_file:s0
    tclass=dir
    
    avc: granted { getattr } for
    path="/data/dalvik-cache/arm64/system@framework@boot.art" dev="dm-2"
    ino=106318 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file
    
    avc: granted { search } for name="dalvik-cache" dev="dm-2" ino=106289
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:dalvikcache_data_file:s0
    tclass=dir
    
    avc: granted { search } for name="arm64" dev="dm-2" ino=106290
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:dalvikcache_data_file:s0
    tclass=dir
    
    avc: granted { read } for name="system@framework@boot.art" dev="dm-2"
    ino=106318 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file
    
    avc: granted { read open } for
    path="/data/dalvik-cache/arm64/system@framework@boot.art" dev="dm-2"
    ino=106318 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file
    
    avc: granted { search } for name="dalvik-cache" dev="dm-2" ino=106289
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:dalvikcache_data_file:s0
    tclass=dir
    
    [  169.349480] type=1400 audit(1477679159.734:129): avc: granted { read
    } for pid=6413 comm="main" name="ipv6_route" dev="proc" ino=4026535947
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.350030] type=1400 audit(1477679159.734:130): avc: granted { read
    open } for pid=6413 comm="main" path="/proc/6413/net/ipv6_route"
    dev="proc" ino=4026535947 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.350361] type=1400 audit(1477679159.734:130): avc: granted { read
    open } for pid=6413 comm="main" path="/proc/6413/net/ipv6_route"
    dev="proc" ino=4026535947 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.350399] type=1400 audit(1477679159.734:131): avc: granted {
    getattr } for pid=6413 comm="main" path="/proc/6413/net/ipv6_route"
    dev="proc" ino=4026535947 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.350963] type=1400 audit(1477679159.734:131): avc: granted {
    getattr } for pid=6413 comm="main" path="/proc/6413/net/ipv6_route"
    dev="proc" ino=4026535947 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.351002] type=1400 audit(1477679159.734:132): avc: granted { read
    } for pid=6413 comm="main" name="if_inet6" dev="proc" ino=4026535946
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.351330] type=1400 audit(1477679159.734:132): avc: granted { read
    } for pid=6413 comm="main" name="if_inet6" dev="proc" ino=4026535946
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.351366] type=1400 audit(1477679159.734:133): avc: granted { read
    open } for pid=6413 comm="main" path="/proc/6413/net/if_inet6"
    dev="proc" ino=4026535946 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.351861] type=1400 audit(1477679159.734:133): avc: granted { read
    open } for pid=6413 comm="main" path="/proc/6413/net/if_inet6"
    dev="proc" ino=4026535946 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.351910] type=1400 audit(1477679159.734:134): avc: granted {
    getattr } for pid=6413 comm="main" path="/proc/6413/net/if_inet6"
    dev="proc" ino=4026535946 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.353105] type=1400 audit(1477679159.734:134): avc: granted {
    getattr } for pid=6413 comm="main" path="/proc/6413/net/if_inet6"
    dev="proc" ino=4026535946 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.353186] type=1400 audit(1477679159.734:135): avc: granted { read
    } for pid=6413 comm="main" name="if_inet6" dev="proc" ino=4026535946
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.353594] type=1400 audit(1477679159.734:135): avc: granted { read
    } for pid=6413 comm="main" name="if_inet6" dev="proc" ino=4026535946
    scontext=u:r:dumpstate:s0 tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.353636] type=1400 audit(1477679159.734:136): avc: granted { read
    open } for pid=6413 comm="main" path="/proc/6413/net/if_inet6"
    dev="proc" ino=4026535946 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.354230] type=1400 audit(1477679159.734:136): avc: granted { read
    open } for pid=6413 comm="main" path="/proc/6413/net/if_inet6"
    dev="proc" ino=4026535946 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.354437] type=1400 audit(1477679159.734:137): avc: granted {
    getattr } for pid=6413 comm="main" path="/proc/6413/net/if_inet6"
    dev="proc" ino=4026535946 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    [  169.395359] type=1400 audit(1477679159.734:137): avc: granted {
    getattr } for pid=6413 comm="main" path="/proc/6413/net/if_inet6"
    dev="proc" ino=4026535946 scontext=u:r:dumpstate:s0
    tcontext=u:object_r:proc_net:s0 tclass=file
    
    Test: policy compiles
    Test: adb bugreport runs without auditallow messages above.
    Bug: 32246161
    Change-Id: Ie0ab2ed3c6babc1f93d3b8ae47c92dd905ebc93a
    79a08e13
domain_deprecated.te 8.43 KiB
# rules removed from the domain attribute

# Read access to properties mapping.
allow domain_deprecated kernel:fd use;
allow domain_deprecated tmpfs:file { read getattr };
allow domain_deprecated tmpfs:lnk_file { read getattr };
auditallow { domain_deprecated -init } kernel:fd use;
auditallow { domain_deprecated -dex2oat } tmpfs:file { read getattr };
auditallow domain_deprecated tmpfs:lnk_file { read getattr };

# Search /storage/emulated tmpfs mount.
allow domain_deprecated tmpfs:dir r_dir_perms;
auditallow { domain_deprecated -appdomain -init -sdcardd -surfaceflinger -system_server -vold -zygote } tmpfs:dir r_dir_perms;

# Inherit or receive open files from others.
allow domain_deprecated system_server:fd use;
auditallow { domain_deprecated -appdomain -netd -surfaceflinger } system_server:fd use;

# Connect to adbd and use a socket transferred from it.
# This is used for e.g. adb backup/restore.
allow domain_deprecated adbd:unix_stream_socket connectto;
allow domain_deprecated adbd:fd use;
allow domain_deprecated adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };
auditallow { domain_deprecated -appdomain -system_server } adbd:unix_stream_socket connectto;
auditallow { domain_deprecated -appdomain -system_server } adbd:fd use;
auditallow { domain_deprecated -appdomain -system_server } adbd:unix_stream_socket { getattr getopt ioctl read write shutdown };

# Root fs.
allow domain_deprecated rootfs:dir r_dir_perms;
allow domain_deprecated rootfs:file r_file_perms;
allow domain_deprecated rootfs:lnk_file r_file_perms;
auditallow { domain_deprecated -healthd -init -installd -priv_app -servicemanager -system_server -ueventd -uncrypt -vold -zygote } rootfs:dir { open getattr read ioctl lock }; # search granted in domain
auditallow { domain_deprecated -healthd -init -installd  -priv_app -servicemanager -system_server -ueventd -uncrypt -vold -zygote } rootfs:file r_file_perms;
auditallow { domain_deprecated -appdomain -healthd -init -installd -priv_app -servicemanager -system_server -ueventd -uncrypt -vold -zygote } rootfs:lnk_file { getattr open ioctl lock }; # read granted in domain

# Device accesses.
allow domain_deprecated device:file read;
auditallow domain_deprecated device:file read;

# System file accesses.
allow domain_deprecated system_file:dir r_dir_perms;
allow domain_deprecated system_file:file r_file_perms;
allow domain_deprecated system_file:lnk_file r_file_perms;
auditallow { domain_deprecated -appdomain -init -rild -surfaceflinger -system_server -zygote } system_file:dir { open read ioctl lock }; # search getattr in domain
auditallow { domain_deprecated -appdomain -init -rild -surfaceflinger -system_server -zygote } system_file:file { ioctl lock }; # read open getattr in domain
auditallow { domain_deprecated -appdomain -init -rild -surfaceflinger -system_server -zygote } system_file:lnk_file { getattr open ioctl lock }; # read in domain

# Read files already opened under /data.
allow domain_deprecated system_data_file:file { getattr read };
allow domain_deprecated system_data_file:lnk_file r_file_perms;
auditallow { domain_deprecated -appdomain -init -sdcardd -system_server -tee } system_data_file:file { getattr read };
auditallow { domain_deprecated -appdomain -init -system_server -tee } system_data_file:lnk_file r_file_perms;

# Read apk files under /data/app.
allow domain_deprecated apk_data_file:dir { getattr search };
allow domain_deprecated apk_data_file:file r_file_perms;
allow domain_deprecated apk_data_file:lnk_file r_file_perms;
auditallow { domain_deprecated -appdomain -dex2oat -init -installd -system_server } apk_data_file:dir { getattr search };
auditallow { domain_deprecated -appdomain -dex2oat -installd -system_server } apk_data_file:file r_file_perms;
auditallow { domain_deprecated -appdomain -dex2oat -installd -system_server } apk_data_file:lnk_file r_file_perms;

# Read /data/dalvik-cache.
allow domain_deprecated dalvikcache_data_file:dir { search getattr };
allow domain_deprecated dalvikcache_data_file:file r_file_perms;
auditallow {
  domain_deprecated
  -appdomain
  -debuggerd
  -dex2oat
  -dumpstate
  -init
  -installd
  -system_server
  -zygote
} dalvikcache_data_file:dir { search getattr };
auditallow {
  domain_deprecated
  -appdomain
  -debuggerd
  -dex2oat
  -dumpstate
  -installd
  -system_server
  -zygote
} dalvikcache_data_file:file r_file_perms;

# Read already opened /cache files.
allow domain_deprecated cache_file:dir r_dir_perms;
allow domain_deprecated cache_file:file { getattr read };
allow domain_deprecated cache_file:lnk_file r_file_perms;
auditallow { domain_deprecated -init -priv_app -system_server -vold } cache_file:dir { open read search ioctl lock };
auditallow { domain_deprecated -appdomain -init -priv_app -system_server -vold } cache_file:dir getattr;
auditallow { domain_deprecated -init -priv_app -system_server -vold } cache_file:file { getattr read };
auditallow { domain_deprecated -init -system_server -vold } cache_file:lnk_file r_file_perms;

#Allow access to ion memory allocation device
allow domain_deprecated ion_device:chr_file rw_file_perms;
# split this auditallow into read and write perms since most domains seem to
# only require read
auditallow { domain_deprecated -appdomain -fingerprintd -keystore -surfaceflinger -system_server -tee -vold -zygote } ion_device:chr_file r_file_perms;
auditallow domain_deprecated ion_device:chr_file { write append };

# Read access to pseudo filesystems.
r_dir_file(domain_deprecated, proc)
r_dir_file(domain_deprecated, sysfs)
r_dir_file(domain_deprecated, inotify)
r_dir_file(domain_deprecated, cgroup)
allow domain_deprecated proc_meminfo:file r_file_perms;
r_dir_file(domain_deprecated, proc_net)
#auditallow domain_deprecated proc:dir r_dir_perms; # r_dir_perms granted in domain
auditallow { domain_deprecated -fsck -fsck_untrusted -init -priv_app -rild -system_server -vold } proc:file r_file_perms;
auditallow { domain_deprecated -fsck -fsck_untrusted -init -priv_app -rild -system_server -vold } proc:lnk_file { open ioctl lock }; # getattr read granted in domain
auditallow { domain_deprecated -bluetooth -fingerprintd -healthd -init -netd -priv_app -rild -system_app -surfaceflinger -system_server -tee -ueventd -vold -wpa } sysfs:dir { open getattr read ioctl lock }; # search granted in domain
auditallow { domain_deprecated -bluetooth -fingerprintd -healthd -init -netd -priv_app -rild -system_app -surfaceflinger -system_server -tee -ueventd -vold -wpa } sysfs:file r_file_perms;
auditallow { domain_deprecated -bluetooth -fingerprintd -healthd -init -netd -priv_app -rild -system_app -surfaceflinger -system_server -tee -ueventd -vold -wpa } sysfs:lnk_file { getattr open ioctl lock }; # read granted in domain
auditallow domain_deprecated inotify:dir r_dir_perms;
auditallow domain_deprecated inotify:{ file lnk_file } r_file_perms;
auditallow { domain_deprecated -appdomain -fingerprintd -healthd -init -inputflinger -installd -keystore -netd -rild -surfaceflinger -system_server -zygote } cgroup:dir r_dir_perms;
auditallow { domain_deprecated -appdomain -fingerprintd -healthd -init -inputflinger -installd -keystore -netd -rild -surfaceflinger -system_server -zygote } cgroup:{ file lnk_file } r_file_perms;
auditallow { domain_deprecated -appdomain -init -priv_app -surfaceflinger -system_server -vold } proc_meminfo:file r_file_perms;
auditallow { domain_deprecated -appdomain -clatd -init -netd -system_server -vold -wpa -zygote } proc_net:dir { open getattr read ioctl lock }; # search granted in domain
auditallow {
  domain_deprecated
  -appdomain
  -clatd
  -dumpstate
  -init
  -netd
  -system_server
  -vold
  -wpa
  -zygote
} proc_net:{ file lnk_file } r_file_perms;

# Get SELinux enforcing status.
allow domain_deprecated selinuxfs:dir r_dir_perms;
allow domain_deprecated selinuxfs:file r_file_perms;
auditallow { domain_deprecated -appdomain -debuggerd -init -installd -keystore -postinstall_dexopt -runas -servicemanager -system_server -ueventd -zygote } selinuxfs:dir { open getattr read ioctl lock }; # search granted in domain
auditallow { domain_deprecated -appdomain -debuggerd -init -installd -keystore -postinstall_dexopt -runas -servicemanager -system_server -ueventd -zygote } selinuxfs:file { open read ioctl lock }; # getattr granted in domain
# World readable asec image contents
allow domain_deprecated asec_public_file:file r_file_perms;
allow domain_deprecated { asec_public_file asec_apk_file }:dir r_dir_perms;
auditallow domain_deprecated asec_public_file:file r_file_perms;
auditallow domain_deprecated { asec_public_file asec_apk_file }:dir r_dir_perms;