Skip to content
Snippets Groups Projects
Commit c27c23fb authored by Max's avatar Max
Browse files

/dev/port does not seem to be used, adding in rules to confirm.

Only init and ueventd have any access to /dev/port, and neither should
have any use for it. As it stands, leaving port in just represents
additional attack surface with no useful functionality, so it should be
removed if possible, not only from Pixel devices, but from all Android
devices.

Test: The phone boots successfully

Bug:33301618
Change-Id: Iedc51590f1ffda02444587d647889ead9bdece3f
parent 65ad9bc1
No related branches found
No related tags found
No related merge requests found
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
/dev/mtp_usb u:object_r:mtp_device:s0 /dev/mtp_usb u:object_r:mtp_device:s0
/dev/pmsg0 u:object_r:pmsg_device:s0 /dev/pmsg0 u:object_r:pmsg_device:s0
/dev/pn544 u:object_r:nfc_device:s0 /dev/pn544 u:object_r:nfc_device:s0
/dev/port u:object_r:port_device:s0
/dev/ppp u:object_r:ppp_device:s0 /dev/ppp u:object_r:ppp_device:s0
/dev/ptmx u:object_r:ptmx_device:s0 /dev/ptmx u:object_r:ptmx_device:s0
/dev/pvrsrvkm u:object_r:gpu_device:s0 /dev/pvrsrvkm u:object_r:gpu_device:s0
......
...@@ -27,6 +27,7 @@ type graphics_device, dev_type; ...@@ -27,6 +27,7 @@ type graphics_device, dev_type;
type hw_random_device, dev_type; type hw_random_device, dev_type;
type input_device, dev_type; type input_device, dev_type;
type kmem_device, dev_type; type kmem_device, dev_type;
type port_device, dev_type;
type log_device, dev_type, mlstrustedobject; type log_device, dev_type, mlstrustedobject;
type mtd_device, dev_type; type mtd_device, dev_type;
type mtp_device, dev_type, mlstrustedobject; type mtp_device, dev_type, mlstrustedobject;
......
...@@ -268,13 +268,18 @@ neverallow * { file_type -exec_type -postinstall_file }:file entrypoint; ...@@ -268,13 +268,18 @@ neverallow * { file_type -exec_type -postinstall_file }:file entrypoint;
# Ensure that nothing in userspace can access /dev/mem or /dev/kmem # Ensure that nothing in userspace can access /dev/mem or /dev/kmem
neverallow { neverallow {
domain domain
-init
-kernel
-shell # For CTS and is restricted to getattr in shell.te -shell # For CTS and is restricted to getattr in shell.te
-ueventd # Further restricted in ueventd.te -ueventd # Further restricted in ueventd.te
} kmem_device:chr_file *; } kmem_device:chr_file *;
neverallow * kmem_device:chr_file ~{ create relabelto unlink setattr getattr }; neverallow * kmem_device:chr_file ~{ create relabelto unlink setattr getattr };
#Ensure that nothing in userspace can access /dev/port
neverallow {
domain
-shell # Shell user should not have any abilities outside of getattr
-ueventd
} port_device:chr_file *;
neverallow * port_device:chr_file ~{ create relabelto unlink setattr getattr };
# Only init should be able to configure kernel usermodehelpers or # Only init should be able to configure kernel usermodehelpers or
# security-sensitive proc settings. # security-sensitive proc settings.
neverallow { domain -init } usermodehelper:file { append write }; neverallow { domain -init } usermodehelper:file { append write };
......
...@@ -184,7 +184,7 @@ allow init { fs_type -contextmount_type -sdcard_type -rootfs }:file { open read ...@@ -184,7 +184,7 @@ allow init { fs_type -contextmount_type -sdcard_type -rootfs }:file { open read
allow init { fs_type -contextmount_type -sdcard_type -rootfs }:dir { open read setattr search }; allow init { fs_type -contextmount_type -sdcard_type -rootfs }:dir { open read setattr search };
# chown/chmod on devices. # chown/chmod on devices.
allow init { dev_type -kmem_device }:chr_file { read open setattr }; allow init { dev_type -kmem_device -port_device }:chr_file { read open setattr };
# Unlabeled file access for upgrades from 4.2. # Unlabeled file access for upgrades from 4.2.
allow init unlabeled:dir { create_dir_perms relabelfrom }; allow init unlabeled:dir { create_dir_perms relabelfrom };
......
...@@ -178,6 +178,7 @@ neverallow shell { ...@@ -178,6 +178,7 @@ neverallow shell {
fuse_device fuse_device
hw_random_device hw_random_device
kmem_device kmem_device
port_device
}:chr_file ~getattr; }:chr_file ~getattr;
# Limit shell to only getattr on blk devices for host side tests. # Limit shell to only getattr on blk devices for host side tests.
......
...@@ -46,5 +46,5 @@ neverallow ueventd property_type:property_service set; ...@@ -46,5 +46,5 @@ neverallow ueventd property_type:property_service set;
# Restrict ueventd access on block devices to maintenence operations. # Restrict ueventd access on block devices to maintenence operations.
neverallow ueventd dev_type:blk_file ~{ getattr relabelfrom relabelto create setattr unlink }; neverallow ueventd dev_type:blk_file ~{ getattr relabelfrom relabelto create setattr unlink };
# Only relabelto as we would never want to relabelfrom kmem_device # Only relabelto as we would never want to relabelfrom kmem_device or port_device
neverallow ueventd kmem_device:chr_file ~{ getattr create setattr unlink relabelto }; neverallow ueventd { kmem_device port_device }:chr_file ~{ getattr create setattr unlink relabelto };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment