Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
# Rules for all domains.
|
|
|
|
|
|
|
|
# Allow reaping by init.
|
|
|
|
allow domain init:process sigchld;
|
|
|
|
|
|
|
|
# Intra-domain accesses.
|
2014-06-18 16:09:35 +02:00
|
|
|
allow domain self:process {
|
|
|
|
fork
|
|
|
|
sigchld
|
|
|
|
sigkill
|
|
|
|
sigstop
|
|
|
|
signull
|
|
|
|
signal
|
|
|
|
getsched
|
|
|
|
setsched
|
|
|
|
getsession
|
|
|
|
getpgid
|
|
|
|
setpgid
|
|
|
|
getcap
|
|
|
|
setcap
|
|
|
|
getattr
|
|
|
|
setrlimit
|
|
|
|
};
|
Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
allow domain self:fd use;
|
2016-02-06 00:13:36 +01:00
|
|
|
allow domain proc:dir r_dir_perms;
|
Start the process of locking down proc/net
Files in /proc/net leak information. This change is the first step in
determining which files apps may use, whitelisting benign access, and
otherwise removing access while providing safe alternative APIs.
To that end, this change:
* Introduces the proc_net_type attribute which will assigned to any
new SELinux types in /proc/net to avoid removing access to privileged
processes. These processes may be evaluated later, but are lower
priority than apps.
* Labels /proc/net/{tcp,tcp6,udp,udp6} as proc_net_vpn due to existing
use by VPN apps. This may be replaced by an alternative API.
* Audits all other proc/net access for apps.
* Audits proc/net access for other processes which are currently
granted broad read access to /proc/net but should not be including
storaged, zygote, clatd, logd, preopt2cachename and vold.
Bug: 9496886
Bug: 68016944
Test: Boot Taimen-userdebug. On both wifi and cellular: stream youtube
navigate maps, send text message, make voice call, make video call.
Verify no avc "granted" messages in the logs.
Test: A few VPN apps including "VPN Monster", "Turbo VPN", and
"Freighter". Verify no logspam with the current setup.
Test: atest CtsNativeNetTestCases
Test: atest netd_integration_test
Test: atest QtaguidPermissionTest
Test: atest FileSystemPermissionTest
Change-Id: I7e49f796a25cf68bc698c6c9206e24af3ae11457
Merged-In: I7e49f796a25cf68bc698c6c9206e24af3ae11457
(cherry picked from commit 087318957f26e921d62f2e234fc14bff3c59030e)
2018-04-10 21:47:48 +02:00
|
|
|
allow domain proc_net_type:dir search;
|
2016-01-26 08:22:12 +01:00
|
|
|
r_dir_file(domain, self)
|
Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
allow domain self:{ fifo_file file } rw_file_perms;
|
2014-02-24 21:06:11 +01:00
|
|
|
allow domain self:unix_dgram_socket { create_socket_perms sendto };
|
|
|
|
allow domain self:unix_stream_socket { create_stream_socket_perms connectto };
|
Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
|
|
|
|
# Inherit or receive open files from others.
|
|
|
|
allow domain init:fd use;
|
|
|
|
|
2014-01-19 03:07:06 +01:00
|
|
|
userdebug_or_eng(`
|
|
|
|
allow domain su:fd use;
|
2017-11-08 21:49:32 +01:00
|
|
|
allow domain su:unix_stream_socket { connectto getattr getopt read write shutdown };
|
|
|
|
allow domain su:unix_dgram_socket sendto;
|
2014-01-19 03:07:06 +01:00
|
|
|
|
2016-03-02 14:57:34 +01:00
|
|
|
allow { domain -init } su:binder { call transfer };
|
2014-03-05 15:50:08 +01:00
|
|
|
|
2014-01-19 03:07:06 +01:00
|
|
|
# Running something like "pm dump com.android.bluetooth" requires
|
|
|
|
# fifo writes
|
|
|
|
allow domain su:fifo_file { write getattr };
|
|
|
|
|
|
|
|
# allow "gdbserver --attach" to work for su.
|
|
|
|
allow domain su:process sigchld;
|
2014-10-31 20:40:12 +01:00
|
|
|
|
|
|
|
# Allow writing coredumps to /cores/*
|
|
|
|
allow domain coredump_file:file create_file_perms;
|
|
|
|
allow domain coredump_file:dir ra_dir_perms;
|
2014-01-19 03:07:06 +01:00
|
|
|
')
|
|
|
|
|
2019-06-14 00:05:15 +02:00
|
|
|
with_native_coverage(`
|
|
|
|
# Allow writing coverage information to /data/misc/trace
|
|
|
|
allow domain method_trace_data_file:dir create_dir_perms;
|
|
|
|
allow domain method_trace_data_file:file create_file_perms;
|
|
|
|
')
|
|
|
|
|
Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
# Root fs.
|
2019-01-24 00:07:40 +01:00
|
|
|
allow domain tmpfs:dir { getattr search };
|
2015-11-06 00:24:22 +01:00
|
|
|
allow domain rootfs:dir search;
|
2016-11-10 22:08:42 +01:00
|
|
|
allow domain rootfs:lnk_file { read getattr };
|
Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
|
|
|
|
# Device accesses.
|
|
|
|
allow domain device:dir search;
|
2013-10-23 19:25:53 +02:00
|
|
|
allow domain dev_type:lnk_file r_file_perms;
|
Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
allow domain devpts:dir search;
|
2021-05-13 02:27:22 +02:00
|
|
|
allow domain dmabuf_heap_device:dir r_dir_perms;
|
2014-03-06 16:16:53 +01:00
|
|
|
allow domain socket_device:dir r_dir_perms;
|
Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
allow domain owntty_device:chr_file rw_file_perms;
|
|
|
|
allow domain null_device:chr_file rw_file_perms;
|
2014-05-20 15:01:55 +02:00
|
|
|
allow domain zero_device:chr_file rw_file_perms;
|
2019-10-16 00:27:28 +02:00
|
|
|
|
|
|
|
# /dev/ashmem is being deprecated by means of constraining and eventually
|
|
|
|
# removing all "open" permissions. We preserve the other permissions.
|
|
|
|
allow domain ashmem_device:chr_file { getattr read ioctl lock map append write };
|
|
|
|
# This device is used by libcutils, which is accessible to everyone.
|
2019-09-24 23:43:00 +02:00
|
|
|
allow domain ashmem_libcutils_device:chr_file rw_file_perms;
|
|
|
|
|
2019-08-21 00:42:58 +02:00
|
|
|
# /dev/binder can be accessed by ... everyone! :)
|
|
|
|
allow { domain -hwservicemanager -vndservicemanager } binder_device:chr_file rw_file_perms;
|
|
|
|
|
2020-09-03 21:07:33 +02:00
|
|
|
# Restrict binder ioctls to an allowlist. Additional ioctl commands may be
|
|
|
|
# added to individual domains, but this sets safe defaults for all processes.
|
|
|
|
allowxperm domain binder_device:chr_file ioctl { unpriv_binder_ioctls };
|
|
|
|
|
2019-12-08 21:11:01 +01:00
|
|
|
# /dev/binderfs needs to be accessed by everyone too!
|
|
|
|
allow domain binderfs:dir { getattr search };
|
|
|
|
allow domain binderfs_logs_proc:dir search;
|
2022-02-24 17:15:56 +01:00
|
|
|
allow domain binderfs_features:dir search;
|
|
|
|
allow domain binderfs_features:file r_file_perms;
|
2019-12-08 21:11:01 +01:00
|
|
|
|
2017-09-26 21:58:29 +02:00
|
|
|
allow { domain -servicemanager -vndservicemanager -isolated_app } hwbinder_device:chr_file rw_file_perms;
|
Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
allow domain ptmx_device:chr_file rw_file_perms;
|
2013-09-10 20:13:15 +02:00
|
|
|
allow domain random_device:chr_file rw_file_perms;
|
2017-11-20 20:02:03 +01:00
|
|
|
allow domain proc_random:dir r_dir_perms;
|
|
|
|
allow domain proc_random:file r_file_perms;
|
2017-01-06 19:28:54 +01:00
|
|
|
allow domain properties_device:dir { search getattr };
|
2015-12-02 01:58:27 +01:00
|
|
|
allow domain properties_serial:file r_file_perms;
|
2017-11-16 23:25:02 +01:00
|
|
|
allow domain property_info:file r_file_perms;
|
2015-12-02 01:58:27 +01:00
|
|
|
|
2017-10-19 09:54:49 +02:00
|
|
|
# Public readable properties
|
2020-06-23 15:01:45 +02:00
|
|
|
get_prop(domain, aaudio_config_prop)
|
2022-01-29 01:16:12 +01:00
|
|
|
get_prop(domain, apexd_select_prop)
|
2020-12-04 02:23:06 +01:00
|
|
|
get_prop(domain, arm64_memtag_prop)
|
2022-01-12 14:05:33 +01:00
|
|
|
get_prop(domain, bluetooth_config_prop)
|
2020-07-23 10:54:35 +02:00
|
|
|
get_prop(domain, bootloader_prop)
|
2020-05-19 15:02:58 +02:00
|
|
|
get_prop(domain, build_odm_prop)
|
2020-05-06 13:07:33 +02:00
|
|
|
get_prop(domain, build_prop)
|
2020-05-19 15:02:58 +02:00
|
|
|
get_prop(domain, build_vendor_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
get_prop(domain, debug_prop)
|
|
|
|
get_prop(domain, exported_config_prop)
|
|
|
|
get_prop(domain, exported_default_prop)
|
|
|
|
get_prop(domain, exported_dumpstate_prop)
|
2018-03-16 00:10:37 +01:00
|
|
|
get_prop(domain, exported_secure_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
get_prop(domain, exported_system_prop)
|
2020-05-06 13:07:33 +02:00
|
|
|
get_prop(domain, fingerprint_prop)
|
2022-03-22 23:59:57 +01:00
|
|
|
get_prop(domain, gwp_asan_prop)
|
2020-07-24 17:34:56 +02:00
|
|
|
get_prop(domain, hal_instrumentation_prop)
|
2021-03-11 21:51:25 +01:00
|
|
|
get_prop(domain, hw_timeout_multiplier_prop)
|
2020-05-28 02:04:36 +02:00
|
|
|
get_prop(domain, init_service_status_prop)
|
2020-05-06 15:20:35 +02:00
|
|
|
get_prop(domain, libc_debug_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
get_prop(domain, logd_prop)
|
2020-05-25 08:36:44 +02:00
|
|
|
get_prop(domain, mediadrm_config_prop)
|
2020-07-24 17:34:56 +02:00
|
|
|
get_prop(domain, property_service_version_prop)
|
2021-01-26 11:25:38 +01:00
|
|
|
get_prop(domain, soc_prop)
|
2020-02-10 10:43:15 +01:00
|
|
|
get_prop(domain, socket_hook_prop)
|
2020-04-24 07:20:53 +02:00
|
|
|
get_prop(domain, surfaceflinger_prop)
|
2020-05-14 14:47:43 +02:00
|
|
|
get_prop(domain, telephony_status_prop)
|
2020-02-10 10:43:15 +01:00
|
|
|
get_prop(domain, vendor_socket_hook_prop)
|
2020-01-06 06:35:57 +01:00
|
|
|
get_prop(domain, vndk_prop)
|
2020-04-06 13:49:17 +02:00
|
|
|
get_prop(domain, vold_status_prop)
|
2020-07-13 19:10:37 +02:00
|
|
|
get_prop(domain, vts_config_prop)
|
2017-10-19 09:54:49 +02:00
|
|
|
|
2020-01-17 19:06:16 +01:00
|
|
|
# Binder cache properties are world-readable
|
|
|
|
get_prop(domain, binder_cache_bluetooth_server_prop)
|
2020-01-11 02:23:45 +01:00
|
|
|
get_prop(domain, binder_cache_system_server_prop)
|
2020-01-28 22:08:28 +01:00
|
|
|
get_prop(domain, binder_cache_telephony_server_prop)
|
2020-01-11 02:23:45 +01:00
|
|
|
|
2016-04-15 20:10:06 +02:00
|
|
|
# Let everyone read log properties, so that liblog can avoid sending unloggable
|
|
|
|
# messages to logd.
|
|
|
|
get_prop(domain, log_property_type)
|
2015-12-02 01:58:27 +01:00
|
|
|
dontaudit domain property_type:file audit_access;
|
2017-03-24 18:22:14 +01:00
|
|
|
allow domain property_contexts_file:file r_file_perms;
|
2015-12-02 01:58:27 +01:00
|
|
|
|
2015-03-11 23:44:14 +01:00
|
|
|
allow domain init:key search;
|
2015-04-29 00:06:29 +02:00
|
|
|
allow domain vold:key search;
|
Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
|
2013-11-13 00:34:52 +01:00
|
|
|
# logd access
|
|
|
|
write_logd(domain)
|
|
|
|
|
2018-08-12 00:34:49 +02:00
|
|
|
# Directory/link file access for path resolution.
|
|
|
|
allow domain {
|
|
|
|
system_file
|
|
|
|
system_lib_file
|
|
|
|
system_seccomp_policy_file
|
|
|
|
system_security_cacerts_file
|
|
|
|
}:dir r_dir_perms;
|
2017-03-03 18:52:16 +01:00
|
|
|
allow domain system_file:lnk_file { getattr read };
|
Enable SELinux protections for netd.
This change does several things:
1) Restore domain.te to the version present at
cd516a32663b4eb11b2e3356b86450020e59e279 . This is the version
currently being distributed in AOSP.
2) Add "allow domain properties_device:file r_file_perms;" to
domain.te, to allow all domains to read /dev/__properties__ .
This change was missing from AOSP.
3) Restore netd.te to the version present at
80c9ba5267f1a6ceffcf979471d101948b520ad6 . This is the version
currently being distributed in AOSP.
4) Remove anything involving module loading from netd.te. CTS
enforces that Android kernels can't have module loading enabled.
5) Add several new capabilities, plus data file rules, to
netd.te, since netd needs to write to files owned by wifi.
6) Add a new unconfined domain called dnsmasq.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the dnsmasq.te domain.
7) Add a new unconfined domain called hostapd.te, and allow
transitions from netd to that domain. Over time, we'll tighten up
the hostapd.te domain.
The net effect of these changes is to re-enable SELinux protections
for netd. The policy is FAR from perfect, and allows a lot of wiggle
room, but we can improve it over time.
Testing: as much as possible, I've exercised networking related
functionality, including turning on and off wifi, entering airplane
mode, and enabling tethering and portable wifi hotspots. It's quite
possible I've missed something, and if we experience problems, I
can roll back this change.
Bug: 9618347
Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
2013-06-28 00:11:02 +02:00
|
|
|
|
2018-08-12 00:34:49 +02:00
|
|
|
# Global access to /system/etc/security/cacerts/*, /system/etc/seccomp_policy/*, /system/lib[64]/*,
|
2019-07-15 22:33:48 +02:00
|
|
|
# /(system|product|system_ext)/etc/(group|passwd), linker and its config.
|
2018-08-12 00:34:49 +02:00
|
|
|
allow domain system_seccomp_policy_file:file r_file_perms;
|
|
|
|
# cacerts are accessible from public Java API.
|
|
|
|
allow domain system_security_cacerts_file:file r_file_perms;
|
2019-07-15 22:33:48 +02:00
|
|
|
allow domain system_group_file:file r_file_perms;
|
|
|
|
allow domain system_passwd_file:file r_file_perms;
|
2018-08-12 00:34:49 +02:00
|
|
|
allow domain system_linker_exec:file { execute read open getattr map };
|
|
|
|
allow domain system_linker_config_file:file r_file_perms;
|
|
|
|
allow domain system_lib_file:file { execute read open getattr map };
|
2019-01-16 15:35:34 +01:00
|
|
|
# To allow following symlinks at /system/bin/linker, /system/lib/libc.so, etc.
|
|
|
|
allow domain system_linker_exec:lnk_file { read open getattr };
|
|
|
|
allow domain system_lib_file:lnk_file { read open getattr };
|
2018-08-12 00:34:49 +02:00
|
|
|
|
2019-01-10 22:59:37 +01:00
|
|
|
allow domain system_event_log_tags_file:file r_file_perms;
|
|
|
|
|
2018-08-12 00:34:49 +02:00
|
|
|
allow { appdomain coredomain } system_file:file { execute read open getattr map };
|
|
|
|
|
2017-04-02 02:17:12 +02:00
|
|
|
# Make sure system/vendor split doesn not affect non-treble
|
|
|
|
# devices
|
|
|
|
not_full_treble(`
|
2018-08-12 00:34:49 +02:00
|
|
|
allow domain system_file:file { execute read open getattr map };
|
2017-04-02 02:17:12 +02:00
|
|
|
allow domain vendor_file_type:dir { search getattr };
|
2017-08-23 07:10:33 +02:00
|
|
|
allow domain vendor_file_type:file { execute read open getattr map };
|
2017-04-02 02:17:12 +02:00
|
|
|
allow domain vendor_file_type:lnk_file { getattr read };
|
|
|
|
')
|
|
|
|
|
|
|
|
# All domains are allowed to open and read directories
|
|
|
|
# that contain HAL implementations (e.g. passthrough
|
|
|
|
# HALs require clients to have these permissions)
|
|
|
|
allow domain vendor_hal_file:dir r_dir_perms;
|
|
|
|
|
|
|
|
# Everyone can read and execute all same process HALs
|
|
|
|
allow domain same_process_hal_file:dir r_dir_perms;
|
2018-10-18 21:39:35 +02:00
|
|
|
allow {
|
|
|
|
domain
|
|
|
|
-coredomain # access is explicitly granted to individual coredomains
|
|
|
|
} same_process_hal_file:file { execute read open getattr map };
|
2017-04-02 02:17:12 +02:00
|
|
|
|
2017-04-10 06:37:40 +02:00
|
|
|
# Any process can load vndk-sp libraries, which are system libraries
|
2017-04-07 14:16:19 +02:00
|
|
|
# used by same process HALs
|
2017-04-10 06:37:40 +02:00
|
|
|
allow domain vndk_sp_file:dir r_dir_perms;
|
2017-08-23 07:10:33 +02:00
|
|
|
allow domain vndk_sp_file:file { execute read open getattr map };
|
2017-04-07 14:16:19 +02:00
|
|
|
|
2017-04-02 02:17:12 +02:00
|
|
|
# All domains get access to /vendor/etc
|
|
|
|
allow domain vendor_configs_file:dir r_dir_perms;
|
2018-06-06 21:32:45 +02:00
|
|
|
allow domain vendor_configs_file:file { read open getattr map };
|
2017-04-02 02:17:12 +02:00
|
|
|
|
|
|
|
full_treble_only(`
|
2018-03-11 11:20:29 +01:00
|
|
|
# Allow all domains to be able to follow /system/vendor and/or
|
|
|
|
# /vendor/odm symlinks.
|
|
|
|
allow domain vendor_file_type:lnk_file { getattr open read };
|
2017-04-10 17:08:13 +02:00
|
|
|
|
|
|
|
# This is required to be able to search & read /vendor/lib64
|
2017-04-10 20:39:27 +02:00
|
|
|
# in order to lookup vendor libraries. The execute permission
|
2017-04-10 17:08:13 +02:00
|
|
|
# for coredomains is granted *only* for same process HALs
|
2017-04-02 02:17:12 +02:00
|
|
|
allow domain vendor_file:dir { getattr search };
|
|
|
|
|
|
|
|
# Allow reading and executing out of /vendor to all vendor domains
|
|
|
|
allow { domain -coredomain } vendor_file_type:dir r_dir_perms;
|
2017-08-23 07:10:33 +02:00
|
|
|
allow { domain -coredomain } vendor_file_type:file { read open getattr execute map };
|
2017-04-02 02:17:12 +02:00
|
|
|
allow { domain -coredomain } vendor_file_type:lnk_file { getattr read };
|
|
|
|
')
|
|
|
|
|
2017-08-28 23:30:26 +02:00
|
|
|
# read and stat any sysfs symlinks
|
|
|
|
allow domain sysfs:lnk_file { getattr read };
|
2016-01-08 00:54:56 +01:00
|
|
|
|
2018-08-12 00:34:49 +02:00
|
|
|
# libc references /data/misc/zoneinfo and /system/usr/share/zoneinfo for
|
|
|
|
# timezone related information.
|
2017-03-31 21:39:27 +02:00
|
|
|
# This directory is considered to be a VNDK-stable
|
2018-09-27 17:45:16 +02:00
|
|
|
allow domain { system_zoneinfo_file zoneinfo_data_file }:file r_file_perms;
|
|
|
|
allow domain { system_zoneinfo_file zoneinfo_data_file }:dir r_dir_perms;
|
2015-11-28 04:18:17 +01:00
|
|
|
|
2015-12-10 20:10:20 +01:00
|
|
|
# Lots of processes access current CPU information
|
|
|
|
r_dir_file(domain, sysfs_devices_system_cpu)
|
|
|
|
|
2016-06-10 18:04:58 +02:00
|
|
|
r_dir_file(domain, sysfs_usb);
|
|
|
|
|
2019-03-13 20:06:01 +01:00
|
|
|
# If kernel CONFIG_TRANSPARENT_HUGEPAGE is enabled, libjemalloc5 (statically
|
|
|
|
# included by libc) reads /sys/kernel/mm/transparent_hugepage/enabled.
|
|
|
|
allow domain sysfs_transparent_hugepage:dir search;
|
|
|
|
allow domain sysfs_transparent_hugepage:file r_file_perms;
|
|
|
|
|
Restrict creating per-user encrypted directories
Creating a per-user encrypted directory such as /data/system_ce/0 and
the subdirectories in it too early has been a recurring bug. Typically,
individual services in system_server are to blame; system_server has
permission to create these directories, and it's easy to write
"mkdirs()" instead of "mkdir()". Such bugs are very bad, as they
prevent these directories from being encrypted, as encryption policies
can only be set on empty directories. Due to recent changes, a factory
reset is now forced in such cases, which helps detect these bugs;
however, it would be much better to prevent them in the first place.
This CL locks down the ability to create these directories to just vold
and init, or to just vold when possible. This is done by assigning new
types to the directories that contain these directories, and then only
allowing the needed domains to write to these parent directories. This
is similar to what https://r.android.com/1117297 did for /data itself.
Three new types are used instead of just one, since these directories
had three different types already (system_data_file, media_rw_data_file,
vendor_data_file), and this allows the policy to be a bit more precise.
A significant limitation is that /data/user/0 is currently being created
by init during early boot. Therefore, this CL doesn't help much for
/data/user/0, though it helps a lot for the other directories. As the
next step, I'll try to eliminate the /data/user/0 quirk. Anyway, this
CL is needed regardless of whether we're able to do that.
Test: Booted cuttlefish. Ran 'sm partition disk:253,32 private', then
created and deleted a user. Used 'ls -lZ' to check the relevant
SELinux labels on both internal and adoptable storage. Also did
similar tests on raven, with the addition of going through the
setup wizard and using an app that creates media files. No
relevant SELinux denials seen during any of this.
Bug: 156305599
Change-Id: I1fbdd180f56dd2fe4703763936f5850cef8ab0ba
2022-05-05 00:18:02 +02:00
|
|
|
# Allow search access, and sometimes getattr access, to various directories
|
|
|
|
# under /data. We are fairly lenient in allowing search access to top-level
|
|
|
|
# dirs that commonly need to be traversed to get access to the "real" files, as
|
|
|
|
# this greatly simplifies the policy and doesn't open up much attack surface.
|
2018-02-08 01:29:06 +01:00
|
|
|
not_full_treble(`
|
|
|
|
allow domain system_data_file:dir getattr;
|
|
|
|
')
|
2017-03-28 07:44:40 +02:00
|
|
|
allow { coredomain appdomain } system_data_file:dir getattr;
|
Restrict creating per-user encrypted directories
Creating a per-user encrypted directory such as /data/system_ce/0 and
the subdirectories in it too early has been a recurring bug. Typically,
individual services in system_server are to blame; system_server has
permission to create these directories, and it's easy to write
"mkdirs()" instead of "mkdir()". Such bugs are very bad, as they
prevent these directories from being encrypted, as encryption policies
can only be set on empty directories. Due to recent changes, a factory
reset is now forced in such cases, which helps detect these bugs;
however, it would be much better to prevent them in the first place.
This CL locks down the ability to create these directories to just vold
and init, or to just vold when possible. This is done by assigning new
types to the directories that contain these directories, and then only
allowing the needed domains to write to these parent directories. This
is similar to what https://r.android.com/1117297 did for /data itself.
Three new types are used instead of just one, since these directories
had three different types already (system_data_file, media_rw_data_file,
vendor_data_file), and this allows the policy to be a bit more precise.
A significant limitation is that /data/user/0 is currently being created
by init during early boot. Therefore, this CL doesn't help much for
/data/user/0, though it helps a lot for the other directories. As the
next step, I'll try to eliminate the /data/user/0 quirk. Anyway, this
CL is needed regardless of whether we're able to do that.
Test: Booted cuttlefish. Ran 'sm partition disk:253,32 private', then
created and deleted a user. Used 'ls -lZ' to check the relevant
SELinux labels on both internal and adoptable storage. Also did
similar tests on raven, with the addition of going through the
setup wizard and using an app that creates media files. No
relevant SELinux denials seen during any of this.
Bug: 156305599
Change-Id: I1fbdd180f56dd2fe4703763936f5850cef8ab0ba
2022-05-05 00:18:02 +02:00
|
|
|
# Anything that accesses anything in /data needs search access to /data itself.
|
|
|
|
# This includes vendor components, as they need to access /data/vendor.
|
2019-08-02 00:57:47 +02:00
|
|
|
allow domain system_data_root_file:dir { search getattr } ;
|
Restrict creating per-user encrypted directories
Creating a per-user encrypted directory such as /data/system_ce/0 and
the subdirectories in it too early has been a recurring bug. Typically,
individual services in system_server are to blame; system_server has
permission to create these directories, and it's easy to write
"mkdirs()" instead of "mkdir()". Such bugs are very bad, as they
prevent these directories from being encrypted, as encryption policies
can only be set on empty directories. Due to recent changes, a factory
reset is now forced in such cases, which helps detect these bugs;
however, it would be much better to prevent them in the first place.
This CL locks down the ability to create these directories to just vold
and init, or to just vold when possible. This is done by assigning new
types to the directories that contain these directories, and then only
allowing the needed domains to write to these parent directories. This
is similar to what https://r.android.com/1117297 did for /data itself.
Three new types are used instead of just one, since these directories
had three different types already (system_data_file, media_rw_data_file,
vendor_data_file), and this allows the policy to be a bit more precise.
A significant limitation is that /data/user/0 is currently being created
by init during early boot. Therefore, this CL doesn't help much for
/data/user/0, though it helps a lot for the other directories. As the
next step, I'll try to eliminate the /data/user/0 quirk. Anyway, this
CL is needed regardless of whether we're able to do that.
Test: Booted cuttlefish. Ran 'sm partition disk:253,32 private', then
created and deleted a user. Used 'ls -lZ' to check the relevant
SELinux labels on both internal and adoptable storage. Also did
similar tests on raven, with the addition of going through the
setup wizard and using an app that creates media files. No
relevant SELinux denials seen during any of this.
Bug: 156305599
Change-Id: I1fbdd180f56dd2fe4703763936f5850cef8ab0ba
2022-05-05 00:18:02 +02:00
|
|
|
# system_data_file is the default type for directories in /data. Anything
|
|
|
|
# accessing data files with a more specific type often has to traverse a
|
|
|
|
# system_data_file directory such as /data/misc to get there.
|
2020-10-15 18:44:52 +02:00
|
|
|
allow domain system_data_file:dir search;
|
Restrict creating per-user encrypted directories
Creating a per-user encrypted directory such as /data/system_ce/0 and
the subdirectories in it too early has been a recurring bug. Typically,
individual services in system_server are to blame; system_server has
permission to create these directories, and it's easy to write
"mkdirs()" instead of "mkdir()". Such bugs are very bad, as they
prevent these directories from being encrypted, as encryption policies
can only be set on empty directories. Due to recent changes, a factory
reset is now forced in such cases, which helps detect these bugs;
however, it would be much better to prevent them in the first place.
This CL locks down the ability to create these directories to just vold
and init, or to just vold when possible. This is done by assigning new
types to the directories that contain these directories, and then only
allowing the needed domains to write to these parent directories. This
is similar to what https://r.android.com/1117297 did for /data itself.
Three new types are used instead of just one, since these directories
had three different types already (system_data_file, media_rw_data_file,
vendor_data_file), and this allows the policy to be a bit more precise.
A significant limitation is that /data/user/0 is currently being created
by init during early boot. Therefore, this CL doesn't help much for
/data/user/0, though it helps a lot for the other directories. As the
next step, I'll try to eliminate the /data/user/0 quirk. Anyway, this
CL is needed regardless of whether we're able to do that.
Test: Booted cuttlefish. Ran 'sm partition disk:253,32 private', then
created and deleted a user. Used 'ls -lZ' to check the relevant
SELinux labels on both internal and adoptable storage. Also did
similar tests on raven, with the addition of going through the
setup wizard and using an app that creates media files. No
relevant SELinux denials seen during any of this.
Bug: 156305599
Change-Id: I1fbdd180f56dd2fe4703763936f5850cef8ab0ba
2022-05-05 00:18:02 +02:00
|
|
|
# Anything that accesses files in /data/user (and /data/user_de, etc.) needs
|
|
|
|
# search access to these directories themselves. getattr access is sometimes
|
|
|
|
# needed too.
|
|
|
|
allow { coredomain appdomain } system_userdir_file:dir { search getattr };
|
|
|
|
# Anything that accesses files in /data/media needs search access to /data/media
|
|
|
|
# itself.
|
|
|
|
allow { coredomain appdomain } media_userdir_file:dir search;
|
2018-02-08 01:29:06 +01:00
|
|
|
# TODO restrict this to non-coredomain
|
Restrict creating per-user encrypted directories
Creating a per-user encrypted directory such as /data/system_ce/0 and
the subdirectories in it too early has been a recurring bug. Typically,
individual services in system_server are to blame; system_server has
permission to create these directories, and it's easy to write
"mkdirs()" instead of "mkdir()". Such bugs are very bad, as they
prevent these directories from being encrypted, as encryption policies
can only be set on empty directories. Due to recent changes, a factory
reset is now forced in such cases, which helps detect these bugs;
however, it would be much better to prevent them in the first place.
This CL locks down the ability to create these directories to just vold
and init, or to just vold when possible. This is done by assigning new
types to the directories that contain these directories, and then only
allowing the needed domains to write to these parent directories. This
is similar to what https://r.android.com/1117297 did for /data itself.
Three new types are used instead of just one, since these directories
had three different types already (system_data_file, media_rw_data_file,
vendor_data_file), and this allows the policy to be a bit more precise.
A significant limitation is that /data/user/0 is currently being created
by init during early boot. Therefore, this CL doesn't help much for
/data/user/0, though it helps a lot for the other directories. As the
next step, I'll try to eliminate the /data/user/0 quirk. Anyway, this
CL is needed regardless of whether we're able to do that.
Test: Booted cuttlefish. Ran 'sm partition disk:253,32 private', then
created and deleted a user. Used 'ls -lZ' to check the relevant
SELinux labels on both internal and adoptable storage. Also did
similar tests on raven, with the addition of going through the
setup wizard and using an app that creates media files. No
relevant SELinux denials seen during any of this.
Bug: 156305599
Change-Id: I1fbdd180f56dd2fe4703763936f5850cef8ab0ba
2022-05-05 00:18:02 +02:00
|
|
|
allow domain vendor_userdir_file:dir { getattr search };
|
2018-02-08 01:29:06 +01:00
|
|
|
allow domain vendor_data_file:dir { getattr search };
|
2015-11-06 00:24:22 +01:00
|
|
|
|
|
|
|
# required by the dynamic linker
|
2016-03-10 22:43:58 +01:00
|
|
|
allow domain proc:lnk_file { getattr read };
|
2015-11-06 00:24:22 +01:00
|
|
|
|
2015-12-23 01:41:27 +01:00
|
|
|
# /proc/cpuinfo
|
|
|
|
allow domain proc_cpuinfo:file r_file_perms;
|
|
|
|
|
2018-11-06 00:03:16 +01:00
|
|
|
# /dev/cpu_variant:.*
|
|
|
|
allow domain dev_cpu_variant:file r_file_perms;
|
|
|
|
|
2017-03-07 02:27:54 +01:00
|
|
|
# profiling needs to read /proc/sys/kernel/perf_event_max_sample_rate
|
|
|
|
allow domain proc_perf:file r_file_perms;
|
|
|
|
|
2015-11-06 00:24:22 +01:00
|
|
|
# toybox loads libselinux which stats /sys/fs/selinux/
|
2016-01-25 19:15:01 +01:00
|
|
|
allow domain selinuxfs:dir search;
|
2015-11-06 00:24:22 +01:00
|
|
|
allow domain selinuxfs:file getattr;
|
|
|
|
allow domain sysfs:dir search;
|
2015-11-19 23:49:58 +01:00
|
|
|
allow domain selinuxfs:filesystem getattr;
|
2014-02-04 17:36:41 +01:00
|
|
|
|
2015-12-08 02:02:31 +01:00
|
|
|
# Almost all processes log tracing information to
|
|
|
|
# /sys/kernel/debug/tracing/trace_marker
|
|
|
|
# The reason behind this is documented in b/6513400
|
|
|
|
allow domain debugfs:dir search;
|
2015-12-14 22:57:26 +01:00
|
|
|
allow domain debugfs_tracing:dir search;
|
2018-01-31 03:14:45 +01:00
|
|
|
allow domain debugfs_tracing_debug:dir search;
|
2015-12-08 02:02:31 +01:00
|
|
|
allow domain debugfs_trace_marker:file w_file_perms;
|
|
|
|
|
2021-03-17 07:57:19 +01:00
|
|
|
# Linux lockdown mode offers coarse-grained definitions for access controls.
|
|
|
|
# The "confidentiality" level detects access to tracefs or the perf subsystem.
|
|
|
|
# This overlaps with more precise declarations in Android's policy. The
|
|
|
|
# debugfs_trace_marker above is an example in which all processes should have
|
|
|
|
# some access to tracefs. Therefore, allow all domains to access this level.
|
|
|
|
# The "integrity" level is however enforced.
|
|
|
|
allow domain self:lockdown confidentiality;
|
|
|
|
|
2016-01-22 00:04:10 +01:00
|
|
|
# Filesystem access.
|
|
|
|
allow domain fs_type:filesystem getattr;
|
|
|
|
allow domain fs_type:dir getattr;
|
|
|
|
|
2020-07-27 18:30:34 +02:00
|
|
|
# Restrict all domains to an allowlist for common socket types. Additional
|
2016-05-17 06:12:17 +02:00
|
|
|
# ioctl commands may be added to individual domains, but this sets safe
|
2020-07-27 18:30:34 +02:00
|
|
|
# defaults for all processes. Note that granting this allowlist to domain does
|
2016-05-17 06:12:17 +02:00
|
|
|
# not grant the ioctl permission on these socket types. That must be granted
|
|
|
|
# separately.
|
2018-06-22 01:57:58 +02:00
|
|
|
allowxperm domain domain:{ icmp_socket rawip_socket tcp_socket udp_socket }
|
2016-05-17 06:12:17 +02:00
|
|
|
ioctl { unpriv_sock_ioctls unpriv_tty_ioctls };
|
2020-07-27 18:30:34 +02:00
|
|
|
# default allowlist for unix sockets.
|
2018-10-17 20:04:06 +02:00
|
|
|
allowxperm domain { domain pdx_channel_socket_type }:{ unix_dgram_socket unix_stream_socket }
|
2016-05-17 06:12:17 +02:00
|
|
|
ioctl unpriv_unix_sock_ioctls;
|
|
|
|
|
2020-07-27 18:30:34 +02:00
|
|
|
# Restrict PTYs to only allowed ioctls.
|
|
|
|
# Note that granting this allowlist to domain does
|
2016-11-22 23:22:43 +01:00
|
|
|
# not grant the wider ioctl permission. That must be granted
|
|
|
|
# separately.
|
|
|
|
allowxperm domain devpts:chr_file ioctl unpriv_tty_ioctls;
|
2016-05-17 06:12:17 +02:00
|
|
|
|
2018-10-09 23:22:47 +02:00
|
|
|
# All domains must clearly enumerate what ioctls they use
|
2018-10-10 18:55:32 +02:00
|
|
|
# on filesystem objects (plain files, directories, symbolic links,
|
2018-10-17 20:04:06 +02:00
|
|
|
# named pipes, and named sockets). We start off with a safe set.
|
2018-10-19 00:07:40 +02:00
|
|
|
allowxperm domain { file_type fs_type domain dev_type }:{ dir notdevfile_class_set blk_file } ioctl { FIOCLEX FIONCLEX };
|
2018-10-09 23:22:47 +02:00
|
|
|
|
2018-10-31 04:12:41 +01:00
|
|
|
# If a domain has ioctl access to tun_device, it must clearly enumerate the
|
|
|
|
# ioctls used. Safe defaults are listed below.
|
|
|
|
allowxperm domain tun_device:chr_file ioctl { FIOCLEX FIONCLEX };
|
|
|
|
|
2018-10-12 21:44:33 +02:00
|
|
|
# Allow a process to make a determination whether a file descriptor
|
2018-10-18 18:10:54 +02:00
|
|
|
# for a plain file or pipe (fifo_file) is a tty. Note that granting
|
2020-07-27 18:30:34 +02:00
|
|
|
# this allowlist to domain does not grant the ioctl permission to
|
2018-10-18 18:10:54 +02:00
|
|
|
# these files. That must be granted separately.
|
2018-10-12 21:44:33 +02:00
|
|
|
allowxperm domain { file_type fs_type }:file ioctl { TCGETS };
|
2018-10-18 18:10:54 +02:00
|
|
|
allowxperm domain domain:fifo_file ioctl { TCGETS };
|
2018-10-12 21:44:33 +02:00
|
|
|
|
2018-10-19 00:07:40 +02:00
|
|
|
# If a domain has access to perform an ioctl on a block device, allow these
|
|
|
|
# very common, benign ioctls
|
|
|
|
allowxperm domain dev_type:blk_file ioctl { BLKGETSIZE64 BLKSSZGET };
|
|
|
|
|
2018-10-09 23:22:47 +02:00
|
|
|
# Support sqlite F2FS specific optimizations
|
|
|
|
# ioctl permission on the specific file type is still required
|
|
|
|
# TODO: consider only compiling these rules if we know the
|
|
|
|
# /data partition is F2FS
|
2018-10-12 21:44:33 +02:00
|
|
|
allowxperm domain { file_type sdcard_type }:file ioctl {
|
2018-10-09 23:22:47 +02:00
|
|
|
F2FS_IOC_ABORT_VOLATILE_WRITE
|
|
|
|
F2FS_IOC_COMMIT_ATOMIC_WRITE
|
|
|
|
F2FS_IOC_GET_FEATURES
|
|
|
|
F2FS_IOC_GET_PIN_FILE
|
|
|
|
F2FS_IOC_SET_PIN_FILE
|
|
|
|
F2FS_IOC_START_ATOMIC_WRITE
|
|
|
|
};
|
|
|
|
|
2017-04-13 22:28:35 +02:00
|
|
|
# Workaround for policy compiler being too aggressive and removing hwservice_manager_type
|
|
|
|
# when it's not explicitly used in allow rules
|
|
|
|
allow { domain -domain } hwservice_manager_type:hwservice_manager { add find };
|
|
|
|
# Workaround for policy compiler being too aggressive and removing vndservice_manager_type
|
|
|
|
# when it's not explicitly used in allow rules
|
2017-04-14 22:50:34 +02:00
|
|
|
allow { domain -domain } vndservice_manager_type:service_manager { add find };
|
2017-04-08 01:14:43 +02:00
|
|
|
|
2017-09-26 21:58:29 +02:00
|
|
|
# Under ASAN, processes will try to read /data, as the sanitized libraries are there.
|
|
|
|
with_asan(`allow domain system_data_file:dir getattr;')
|
2018-10-07 01:16:46 +02:00
|
|
|
# Under ASAN, /system/asan.options needs to be globally accessible.
|
|
|
|
with_asan(`allow domain system_asan_options_file:file r_file_perms;')
|
2017-09-26 21:58:29 +02:00
|
|
|
|
2018-10-16 09:02:49 +02:00
|
|
|
# read APEX dir and stat any symlink pointing to APEXs.
|
2018-11-16 10:10:50 +01:00
|
|
|
allow domain apex_mnt_dir:dir { getattr search };
|
2018-10-16 09:02:49 +02:00
|
|
|
allow domain apex_mnt_dir:lnk_file r_file_perms;
|
|
|
|
|
2013-07-16 02:10:35 +02:00
|
|
|
###
|
|
|
|
### neverallow rules
|
|
|
|
###
|
|
|
|
|
2018-10-17 20:04:06 +02:00
|
|
|
# All ioctls on file-like objects (except chr_file and blk_file) and
|
2020-07-27 18:30:34 +02:00
|
|
|
# sockets must be restricted to an allowlist.
|
2018-10-19 00:07:40 +02:00
|
|
|
neverallowxperm * *:{ dir notdevfile_class_set socket_class_set blk_file } ioctl { 0 };
|
2016-05-17 06:12:17 +02:00
|
|
|
|
2017-10-20 04:51:46 +02:00
|
|
|
# b/68014825 and https://android-review.googlesource.com/516535
|
|
|
|
# rfc6093 says that processes should not use the TCP urgent mechanism
|
|
|
|
neverallowxperm domain domain:socket_class_set ioctl { SIOCATMARK };
|
|
|
|
|
2016-11-22 23:22:43 +01:00
|
|
|
# TIOCSTI is only ever used for exploits. Block it.
|
|
|
|
# b/33073072, b/7530569
|
|
|
|
# http://www.openwall.com/lists/oss-security/2016/09/26/14
|
|
|
|
neverallowxperm * devpts:chr_file ioctl TIOCSTI;
|
|
|
|
|
2017-11-21 21:56:30 +01:00
|
|
|
# Do not allow any domain other than init to create unlabeled files.
|
2017-12-11 18:22:01 +01:00
|
|
|
neverallow { domain -init -recovery } unlabeled:dir_file_class_set create;
|
2014-05-29 22:37:13 +02:00
|
|
|
|
2020-07-27 18:30:34 +02:00
|
|
|
# Limit device node creation to these allowed domains.
|
Allow /dev/klog access, drop mknod and __null__ access
Allow vold, healthd, slideshow, and watchdogd access to /dev/kmsg.
These processes log to the kernel dmesg ring buffer, so they need
write access to that file.
Addresses the following denials:
avc: denied { write } for pid=134 comm="watchdogd" name="kmsg" dev="tmpfs" ino=9248 scontext=u:r:watchdogd:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
avc: denied { write } for pid=166 comm="healthd" name="kmsg" dev="tmpfs" ino=9248 scontext=u:r:healthd:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
avc: denied { write } for pid=180 comm="vold" name="kmsg" dev="tmpfs" ino=9248 scontext=u:r:vold:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
These denials were triggered by the change in
https://android-review.googlesource.com/151209 . Prior to that change,
any code which called klog_init would (unnecessarily) create the
device node themselves, rather than using the already existing device
node.
Drop special /dev/__null__ handling from watchdogd. As of
https://android-review.googlesource.com/148288 , watchdogd no longer
creates it's own /dev/null device, so it's unnecessary for us
to allow for it.
Drop mknod from healthd, slideshow, and watchdogd. healthd and slideshow
only needed mknod to create /dev/__kmsg__, which is now obsolete.
watchdogd only needed mknod to create /dev/__kmsg__ and /dev/__null__,
which again is now obsolete.
Bug: 21242418
Change-Id: If01c8001084575e7441253f0fa8b4179ae33f534
2015-06-06 16:42:37 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-kernel
|
|
|
|
-init
|
|
|
|
-ueventd
|
|
|
|
-vold
|
2017-11-09 23:51:26 +01:00
|
|
|
} self:global_capability_class_set mknod;
|
2014-07-10 05:04:59 +02:00
|
|
|
|
2014-05-14 20:05:49 +02:00
|
|
|
# No process can map low memory (< CONFIG_LSM_MMAP_MIN_ADDR).
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * self:memprotect mmap_zero;
|
2014-05-14 20:05:49 +02:00
|
|
|
|
2014-02-10 22:31:04 +01:00
|
|
|
# No domain needs mac_override as it is unused by SELinux.
|
2017-11-09 23:51:26 +01:00
|
|
|
neverallow * self:global_capability2_class_set mac_override;
|
2014-02-10 22:31:04 +01:00
|
|
|
|
2017-11-21 21:56:30 +01:00
|
|
|
# Disallow attempts to set contexts not defined in current policy
|
|
|
|
# This helps guarantee that unknown or dangerous contents will not ever
|
|
|
|
# be set.
|
|
|
|
neverallow * self:global_capability2_class_set mac_admin;
|
2014-01-30 19:23:08 +01:00
|
|
|
|
2016-03-10 13:58:23 +01:00
|
|
|
# Once the policy has been loaded there shall be none to modify the policy.
|
|
|
|
# It is sealed.
|
|
|
|
neverallow * kernel:security load_policy;
|
2014-05-30 16:25:00 +02:00
|
|
|
|
2013-12-06 14:05:53 +01:00
|
|
|
# Only init prior to switching context should be able to set enforcing mode.
|
|
|
|
# init starts in kernel domain and switches to init domain via setcon in
|
|
|
|
# the init.rc, so the setenforce occurs while still in kernel. After
|
|
|
|
# switching domains, there is never any need to setenforce again by init.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * kernel:security setenforce;
|
2014-05-12 23:32:59 +02:00
|
|
|
neverallow { domain -kernel } kernel:security setcheckreqprot;
|
2013-09-27 16:38:14 +02:00
|
|
|
|
2014-03-06 19:02:50 +01:00
|
|
|
# No booleans in AOSP policy, so no need to ever set them.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * kernel:security setbool;
|
2014-03-06 19:02:50 +01:00
|
|
|
|
|
|
|
# Adjusting the AVC cache threshold.
|
|
|
|
# Not presently allowed to anything in policy, but possibly something
|
|
|
|
# that could be set from init.rc.
|
|
|
|
neverallow { domain -init } kernel:security setsecparam;
|
|
|
|
|
2021-02-08 21:22:39 +01:00
|
|
|
# Only the kernel hwrng thread should be able to read from the HW RNG.
|
2016-03-24 01:26:42 +01:00
|
|
|
neverallow {
|
|
|
|
domain
|
2021-02-08 21:22:39 +01:00
|
|
|
-shell # For CTS, restricted to just getattr in shell.te
|
|
|
|
-ueventd # To create the /dev/hw_random file
|
2016-03-24 01:26:42 +01:00
|
|
|
} hw_random_device:chr_file *;
|
2018-04-17 19:55:41 +02:00
|
|
|
# b/78174219 b/64114943
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-shell # stat of /dev, getattr only
|
|
|
|
-ueventd
|
|
|
|
} keychord_device:chr_file *;
|
2013-10-03 22:35:56 +02:00
|
|
|
|
2016-04-06 01:07:25 +02:00
|
|
|
# Ensure that all entrypoint executables are in exec_type or postinstall_file.
|
|
|
|
neverallow * { file_type -exec_type -postinstall_file }:file entrypoint;
|
2013-10-31 19:17:23 +01:00
|
|
|
|
2019-01-25 10:22:18 +01:00
|
|
|
# The dynamic linker always calls access(2) on the path. Don't generate SElinux
|
|
|
|
# denials since the linker does not actually access the path in case the path
|
|
|
|
# does not exist or isn't accessible for the process.
|
|
|
|
dontaudit domain postinstall_mnt_dir:dir audit_access;
|
|
|
|
|
2016-12-05 00:11:29 +01:00
|
|
|
#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 };
|
2013-12-06 15:31:40 +01:00
|
|
|
# Only init should be able to configure kernel usermodehelpers or
|
|
|
|
# security-sensitive proc settings.
|
|
|
|
neverallow { domain -init } usermodehelper:file { append write };
|
2017-09-26 21:58:29 +02:00
|
|
|
neverallow { domain -init -ueventd } sysfs_usermodehelper:file { append write };
|
2017-09-28 23:34:36 +02:00
|
|
|
neverallow { domain -init -vendor_init } proc_security:file { append open read write };
|
2013-12-09 18:49:47 +01:00
|
|
|
|
2019-07-10 19:13:19 +02:00
|
|
|
# Init can't do anything with binder calls. If this neverallow rule is being
|
|
|
|
# triggered, it's probably due to a service with no SELinux domain.
|
|
|
|
neverallow * init:binder *;
|
2018-02-09 20:31:56 +01:00
|
|
|
neverallow * vendor_init:binder *;
|
2014-01-30 18:10:28 +01:00
|
|
|
|
|
|
|
# Don't allow raw read/write/open access to block_device
|
|
|
|
# Rather force a relabel to a more specific type
|
2016-02-10 18:33:08 +01:00
|
|
|
neverallow { domain -kernel -init -recovery } block_device:blk_file { open read write };
|
2014-01-30 18:15:45 +01:00
|
|
|
|
2017-01-20 23:26:05 +01:00
|
|
|
# Do not allow renaming of block files or character files
|
|
|
|
# Ability to do so can lead to possible use in an exploit chain
|
|
|
|
# e.g. https://googleprojectzero.blogspot.com/2016/12/chrome-os-exploit-one-byte-overflow-and.html
|
|
|
|
neverallow * *:{ blk_file chr_file } rename;
|
|
|
|
|
2014-01-30 18:15:45 +01:00
|
|
|
# Don't allow raw read/write/open access to generic devices.
|
|
|
|
# Rather force a relabel to a more specific type.
|
2017-01-27 21:39:45 +01:00
|
|
|
neverallow domain device:chr_file { open read write };
|
2014-02-10 19:29:38 +01:00
|
|
|
|
2015-05-14 22:16:40 +02:00
|
|
|
# Files from cache should never be executed
|
2016-01-28 20:30:41 +01:00
|
|
|
neverallow domain { cache_file cache_backup_file cache_private_backup_file cache_recovery_file }:file execute;
|
2014-05-29 15:22:16 +02:00
|
|
|
|
2018-02-20 21:41:30 +01:00
|
|
|
# The test files and executables MUST not be accessible to any domain
|
2018-05-09 15:12:50 +02:00
|
|
|
neverallow { domain userdebug_or_eng(`-kernel') } nativetest_data_file:file_class_set no_w_file_perms;
|
2018-02-20 21:41:30 +01:00
|
|
|
neverallow domain nativetest_data_file:dir no_w_dir_perms;
|
2015-10-29 00:45:58 +01:00
|
|
|
neverallow { domain userdebug_or_eng(`-shell') } nativetest_data_file:file no_x_file_perms;
|
|
|
|
|
2020-09-01 01:11:11 +02:00
|
|
|
neverallow { domain -shell -init -adbd } shell_test_data_file:file_class_set no_w_file_perms;
|
|
|
|
neverallow { domain -shell -init -adbd } shell_test_data_file:dir no_w_dir_perms;
|
2021-09-08 21:41:47 +02:00
|
|
|
neverallow { domain -shell -init -adbd -heapprofd -crash_dump } shell_test_data_file:file *;
|
2021-02-09 14:28:49 +01:00
|
|
|
neverallow heapprofd shell_test_data_file:file { no_w_file_perms no_x_file_perms };
|
2021-02-09 14:29:05 +01:00
|
|
|
neverallow { domain -shell -init -adbd } shell_test_data_file:sock_file *;
|
2020-09-01 01:11:11 +02:00
|
|
|
|
2016-03-25 21:59:55 +01:00
|
|
|
# Only the init property service should write to /data/property and /dev/__properties__
|
2014-11-06 00:30:41 +01:00
|
|
|
neverallow { domain -init } property_data_file:dir no_w_dir_perms;
|
2016-04-22 02:08:41 +02:00
|
|
|
neverallow { domain -init } property_data_file:file { no_w_file_perms no_x_file_perms };
|
|
|
|
neverallow { domain -init } property_type:file { no_w_file_perms no_x_file_perms };
|
|
|
|
neverallow { domain -init } properties_device:file { no_w_file_perms no_x_file_perms };
|
|
|
|
neverallow { domain -init } properties_serial:file { no_w_file_perms no_x_file_perms };
|
2014-05-20 20:09:16 +02:00
|
|
|
|
2017-11-21 21:56:30 +01:00
|
|
|
# Nobody should be doing writes to /system & /vendor
|
|
|
|
# These partitions are intended to be read-only and must never be
|
|
|
|
# modified. Doing so would violate important Android security guarantees
|
|
|
|
# and invalidate dm-verity signatures.
|
2017-04-02 02:17:12 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
with_asan(`-asan_extract')
|
2018-10-15 18:00:38 +02:00
|
|
|
recovery_only(`userdebug_or_eng(`-fastbootd')')
|
2017-04-02 02:17:12 +02:00
|
|
|
} {
|
2018-09-27 19:21:37 +02:00
|
|
|
system_file_type
|
2017-04-02 02:17:12 +02:00
|
|
|
vendor_file_type
|
|
|
|
exec_type
|
|
|
|
}:dir_file_class_set { create write setattr relabelfrom append unlink link rename };
|
|
|
|
|
2018-09-27 19:21:37 +02:00
|
|
|
neverallow { domain -kernel with_asan(`-asan_extract') } { system_file_type vendor_file_type exec_type }:dir_file_class_set relabelto;
|
2014-06-16 19:05:38 +02:00
|
|
|
|
2015-02-05 18:23:13 +01:00
|
|
|
# Don't allow mounting on top of /system files or directories
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * exec_type:dir_file_class_set mounton;
|
2015-02-05 18:23:13 +01:00
|
|
|
|
2014-06-19 17:26:22 +02:00
|
|
|
# Nothing should be writing to files in the rootfs.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * rootfs:file { create write setattr relabelto append unlink link rename };
|
2014-06-19 17:26:22 +02:00
|
|
|
|
2014-06-16 19:05:38 +02:00
|
|
|
# Restrict context mounts to specific types marked with
|
|
|
|
# the contextmount_type attribute.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * {fs_type -contextmount_type}:filesystem relabelto;
|
2014-06-16 19:05:38 +02:00
|
|
|
|
|
|
|
# Ensure that context mount types are not writable, to ensure that
|
|
|
|
# the write to /system restriction above is not bypassed via context=
|
|
|
|
# mount to another type.
|
2017-11-21 21:56:30 +01:00
|
|
|
neverallow * contextmount_type:dir_file_class_set
|
2018-10-15 18:00:38 +02:00
|
|
|
{ create setattr relabelfrom relabelto append link rename };
|
|
|
|
neverallow { domain recovery_only(`userdebug_or_eng(`-fastbootd')') } contextmount_type:dir_file_class_set { write unlink };
|
2014-07-07 18:27:53 +02:00
|
|
|
|
2017-04-28 21:45:30 +02:00
|
|
|
# Do not allow service_manager add for default service labels.
|
2014-07-07 18:27:53 +02:00
|
|
|
# Instead domains should use a more specific type such as
|
|
|
|
# system_app_service rather than the generic type.
|
2017-04-28 21:45:30 +02:00
|
|
|
# New service_types are defined in {,hw,vnd}service.te and new mappings
|
|
|
|
# from service name to service_type are defined in {,hw,vnd}service_contexts.
|
2020-01-21 19:18:57 +01:00
|
|
|
neverallow * default_android_service:service_manager *;
|
|
|
|
neverallow * default_android_vndservice:service_manager *;
|
|
|
|
neverallow * default_android_hwservice:hwservice_manager *;
|
2017-04-14 04:05:27 +02:00
|
|
|
|
|
|
|
# Looking up the base class/interface of all HwBinder services is a bad idea.
|
|
|
|
# hwservicemanager currently offer such lookups only to make it so that security
|
|
|
|
# decisions are expressed in SELinux policy. However, it's unclear whether this
|
|
|
|
# lookup has security implications. If it doesn't, hwservicemanager should be
|
|
|
|
# modified to not offer this lookup.
|
|
|
|
# This rule can be removed if hwservicemanager is modified to not permit these
|
|
|
|
# lookups.
|
|
|
|
neverallow * hidl_base_hwservice:hwservice_manager find;
|
|
|
|
|
2014-08-23 00:08:39 +02:00
|
|
|
# Require that domains explicitly label unknown properties, and do not allow
|
|
|
|
# anyone but init to modify unknown properties.
|
2018-01-20 00:21:42 +01:00
|
|
|
neverallow { domain -init -vendor_init } mmc_prop:property_service set;
|
2020-01-06 06:35:57 +01:00
|
|
|
neverallow { domain -init -vendor_init } vndk_prop:property_service set;
|
2014-09-08 22:11:01 +02:00
|
|
|
|
2017-10-19 09:54:49 +02:00
|
|
|
compatible_property_only(`
|
2018-01-20 00:21:42 +01:00
|
|
|
neverallow { domain -init } mmc_prop:property_service set;
|
2017-10-19 09:54:49 +02:00
|
|
|
neverallow { domain -init -vendor_init } exported_default_prop:property_service set;
|
2018-03-16 00:10:37 +01:00
|
|
|
neverallow { domain -init } exported_secure_prop:property_service set;
|
2017-10-19 09:54:49 +02:00
|
|
|
neverallow { domain -init -vendor_init } vendor_default_prop:property_service set;
|
2020-04-10 14:11:49 +02:00
|
|
|
neverallow { domain -init -vendor_init } storage_config_prop:property_service set;
|
2021-03-11 21:51:25 +01:00
|
|
|
neverallow { domain -init -vendor_init } hw_timeout_multiplier_prop:property_service set;
|
2017-10-19 09:54:49 +02:00
|
|
|
')
|
|
|
|
|
|
|
|
compatible_property_only(`
|
|
|
|
neverallow { domain -init -system_server -vendor_init } exported_pm_prop:property_service set;
|
|
|
|
neverallow { domain -coredomain -vendor_init } exported_pm_prop:file no_rw_file_perms;
|
|
|
|
')
|
|
|
|
|
2020-05-06 11:30:20 +02:00
|
|
|
neverallow { domain -init } aac_drc_prop:property_service set;
|
2020-05-06 13:07:33 +02:00
|
|
|
neverallow { domain -init } build_prop:property_service set;
|
2020-05-06 11:30:20 +02:00
|
|
|
|
2016-12-21 00:31:37 +01:00
|
|
|
# Do not allow reading device's serial number from system properties except form
|
2020-07-27 18:30:34 +02:00
|
|
|
# a few allowed domains.
|
2016-12-21 00:31:37 +01:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-adbd
|
|
|
|
-dumpstate
|
2018-05-29 19:54:16 +02:00
|
|
|
-fastbootd
|
2019-03-13 01:57:48 +01:00
|
|
|
-hal_camera_server
|
2017-11-21 06:43:25 +01:00
|
|
|
-hal_cas_server
|
2019-03-13 01:57:48 +01:00
|
|
|
-hal_drm_server
|
2019-10-25 22:45:06 +02:00
|
|
|
userdebug_or_eng(`-incidentd')
|
2016-12-21 00:31:37 +01:00
|
|
|
-init
|
|
|
|
-mediadrmserver
|
2019-11-22 23:47:15 +01:00
|
|
|
-mediaserver
|
2016-12-21 00:31:37 +01:00
|
|
|
-recovery
|
2016-12-29 02:44:33 +01:00
|
|
|
-shell
|
2016-12-21 00:31:37 +01:00
|
|
|
-system_server
|
2017-09-28 23:34:36 +02:00
|
|
|
-vendor_init
|
2016-12-21 00:31:37 +01:00
|
|
|
} serialno_prop:file r_file_perms;
|
|
|
|
|
2016-04-05 17:19:27 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-init
|
|
|
|
-recovery
|
|
|
|
-system_server
|
|
|
|
-shell # Shell is further restricted in shell.te
|
2016-06-03 00:06:02 +02:00
|
|
|
-ueventd # Further restricted in ueventd.te
|
2017-02-17 21:47:25 +01:00
|
|
|
} frp_block_device:blk_file no_rw_file_perms;
|
2014-09-30 18:53:12 +02:00
|
|
|
|
2016-12-15 17:27:16 +01:00
|
|
|
# The metadata block device is set aside for device encryption and
|
|
|
|
# verified boot metadata. It may be reset at will and should not
|
|
|
|
# be used by other domains.
|
2017-12-12 19:30:09 +01:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-init
|
|
|
|
-recovery
|
|
|
|
-vold
|
|
|
|
-e2fs
|
|
|
|
-fsck
|
2018-09-12 21:42:59 +02:00
|
|
|
-fastbootd
|
2017-12-12 19:30:09 +01:00
|
|
|
} metadata_block_device:blk_file { append link rename write open read ioctl lock };
|
2016-12-15 17:27:16 +01:00
|
|
|
|
2018-05-29 19:54:16 +02:00
|
|
|
# No domain other than recovery, update_engine and fastbootd can write to system partition(s).
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-fastbootd
|
2019-02-11 18:58:18 +01:00
|
|
|
userdebug_or_eng(`-fsck')
|
|
|
|
userdebug_or_eng(`-init')
|
2018-05-29 19:54:16 +02:00
|
|
|
-recovery
|
|
|
|
-update_engine
|
|
|
|
} system_block_device:blk_file { write append };
|
2014-09-30 18:53:12 +02:00
|
|
|
|
2017-03-22 00:01:52 +01:00
|
|
|
# Only (hw|vnd|)servicemanager should be able to register with binder as the context manager
|
|
|
|
neverallow { domain -servicemanager -hwservicemanager -vndservicemanager } *:binder set_context_mgr;
|
2016-05-24 15:15:23 +02:00
|
|
|
# The service managers are only allowed to access their own device node
|
|
|
|
neverallow servicemanager hwbinder_device:chr_file no_rw_file_perms;
|
2017-03-22 00:01:52 +01:00
|
|
|
neverallow servicemanager vndbinder_device:chr_file no_rw_file_perms;
|
2016-05-24 15:15:23 +02:00
|
|
|
neverallow hwservicemanager binder_device:chr_file no_rw_file_perms;
|
2017-03-22 00:01:52 +01:00
|
|
|
neverallow hwservicemanager vndbinder_device:chr_file no_rw_file_perms;
|
|
|
|
neverallow vndservicemanager binder_device:chr_file no_rw_file_perms;
|
|
|
|
neverallow vndservicemanager hwbinder_device:chr_file no_rw_file_perms;
|
Add compile time checks for /data/dalvik-cache access
Add an SELinux neverallow rule (compile time assertion) that only
authorized SELinux domains are writing to files in /data/dalvik-cache.
Currently, SELinux policy only allows the following SELinux domains
to perform writes to files in /data/dalvik-cache
* init
* zygote
* installd
* dex2oat
For zygote, installd, and dex2oat, these accesses make sense.
For init, we could further restrict init to just relabelfrom
on /data/dalvik-cache files, and { create, write, setattr }
on /data/dalvik-cache directories. Currently init has full
write access, which can be reduced over time.
This change was motivated by the discussion
in https://android-review.googlesource.com/127582
Remove /data/dalvik-cache access from the unconfined domain.
This domain is only used by init, kernel, and fsck on user builds.
The kernel and fsck domains have no need to access files in
/data/dalvik-cache. Init has a need to relabel files, but
that rule is already granted in init.te.
The neverallow rule is intended to prevent regressions. Neverallow
rules are CTS tested, so regressions won't appear on our devices
or partner devices.
Change-Id: I15e7d17b1121c556463114d1c6c49557a57911cd
2015-01-30 19:29:30 +01:00
|
|
|
|
2019-08-21 00:42:58 +02:00
|
|
|
# system services cant add vendor services
|
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
} vendor_service:service_manager add;
|
2019-03-26 00:27:44 +01:00
|
|
|
|
2019-08-27 19:37:59 +02:00
|
|
|
full_treble_only(`
|
|
|
|
# vendor services cant add system services
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-coredomain
|
|
|
|
} {
|
|
|
|
service_manager_type
|
|
|
|
-vendor_service
|
|
|
|
}:service_manager add;
|
|
|
|
')
|
2019-03-26 00:27:44 +01:00
|
|
|
|
2018-02-23 06:51:24 +01:00
|
|
|
full_treble_only(`
|
2017-03-29 23:49:44 +02:00
|
|
|
# Vendor apps are permited to use only stable public services. If they were to use arbitrary
|
|
|
|
# services which can change any time framework/core is updated, breakage is likely.
|
2020-10-08 00:25:38 +02:00
|
|
|
#
|
|
|
|
# Note, this same logic applies to untrusted apps, but neverallows for these are separate.
|
2017-03-29 23:49:44 +02:00
|
|
|
neverallow {
|
|
|
|
appdomain
|
|
|
|
-coredomain
|
|
|
|
} {
|
|
|
|
service_manager_type
|
2020-10-08 00:25:38 +02:00
|
|
|
|
2017-03-29 23:49:44 +02:00
|
|
|
-app_api_service
|
2020-10-08 00:25:38 +02:00
|
|
|
-vendor_service # must be @VintfStability to be used by an app
|
2017-03-29 23:49:44 +02:00
|
|
|
-ephemeral_app_api_service
|
2020-10-08 00:25:38 +02:00
|
|
|
|
2020-12-02 03:55:11 +01:00
|
|
|
-apc_service
|
2017-03-29 23:49:44 +02:00
|
|
|
-audioserver_service # TODO(b/36783122) remove exemptions below once app_api_service is fixed
|
|
|
|
-cameraserver_service
|
|
|
|
-drmserver_service
|
2020-01-17 22:47:53 +01:00
|
|
|
-credstore_service
|
2021-03-16 03:04:03 +01:00
|
|
|
-keystore_maintenance_service
|
2017-03-29 23:49:44 +02:00
|
|
|
-keystore_service
|
2021-06-15 17:01:16 +02:00
|
|
|
-legacykeystore_service
|
2017-03-29 23:49:44 +02:00
|
|
|
-mediadrmserver_service
|
|
|
|
-mediaextractor_service
|
|
|
|
-mediametrics_service
|
|
|
|
-mediaserver_service
|
|
|
|
-nfc_service
|
|
|
|
-radio_service
|
2017-04-20 22:17:07 +02:00
|
|
|
-virtual_touchpad_service
|
2017-03-29 23:49:44 +02:00
|
|
|
-vr_manager_service
|
2020-09-25 20:38:42 +02:00
|
|
|
userdebug_or_eng(`-hal_face_service')
|
2017-03-29 23:49:44 +02:00
|
|
|
}:service_manager find;
|
2018-02-23 06:51:24 +01:00
|
|
|
')
|
2017-03-28 07:44:40 +02:00
|
|
|
|
2017-04-25 18:27:54 +02:00
|
|
|
# On full TREBLE devices, only vendor components, shell, and su can use VendorBinder.
|
|
|
|
full_treble_only(`
|
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-shell
|
|
|
|
userdebug_or_eng(`-su')
|
|
|
|
-ueventd # uevent is granted create for this device, but we still neverallow I/O below
|
|
|
|
} vndbinder_device:chr_file rw_file_perms;
|
2018-02-23 06:51:24 +01:00
|
|
|
')
|
|
|
|
full_treble_only(`
|
2017-04-25 18:27:54 +02:00
|
|
|
neverallow ueventd vndbinder_device:chr_file { read write append ioctl };
|
2018-02-23 06:51:24 +01:00
|
|
|
')
|
|
|
|
full_treble_only(`
|
2017-04-25 18:27:54 +02:00
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-shell
|
|
|
|
userdebug_or_eng(`-su')
|
|
|
|
} vndservice_manager_type:service_manager *;
|
2018-02-23 06:51:24 +01:00
|
|
|
')
|
|
|
|
full_treble_only(`
|
2017-04-25 18:27:54 +02:00
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-shell
|
|
|
|
userdebug_or_eng(`-su')
|
|
|
|
} vndservicemanager:binder *;
|
|
|
|
')
|
|
|
|
|
2017-03-25 00:07:35 +01:00
|
|
|
# On full TREBLE devices, socket communications between core components and vendor components are
|
|
|
|
# not permitted.
|
|
|
|
# Most general rules first, more specific rules below.
|
|
|
|
|
|
|
|
# Core domains are not permitted to initiate communications to vendor domain sockets.
|
|
|
|
# We are not restricting the use of already established sockets because it is fine for a process
|
|
|
|
# to obtain an already established socket via some public/official/stable API and then exchange
|
|
|
|
# data with its peer over that socket. The wire format in this scenario is dicatated by the API
|
|
|
|
# and thus does not break the core-vendor separation.
|
2018-01-24 16:01:13 +01:00
|
|
|
full_treble_only(`
|
2017-03-25 00:07:35 +01:00
|
|
|
neverallow_establish_socket_comms({
|
|
|
|
coredomain
|
|
|
|
-init
|
|
|
|
-adbd
|
|
|
|
}, {
|
|
|
|
domain
|
|
|
|
-coredomain
|
|
|
|
-socket_between_core_and_vendor_violators
|
|
|
|
});
|
2018-01-24 16:01:13 +01:00
|
|
|
')
|
2017-03-25 00:07:35 +01:00
|
|
|
|
2017-03-31 02:39:00 +02:00
|
|
|
# Vendor domains are not permitted to initiate create/open sockets owned by core domains
|
2018-01-24 16:01:13 +01:00
|
|
|
full_treble_only(`
|
2017-03-31 02:39:00 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-coredomain
|
|
|
|
-appdomain # appdomain restrictions below
|
2018-01-24 16:01:13 +01:00
|
|
|
-data_between_core_and_vendor_violators # b/70393317
|
2017-03-31 02:39:00 +02:00
|
|
|
-socket_between_core_and_vendor_violators
|
2018-01-25 20:31:09 +01:00
|
|
|
-vendor_init
|
2017-03-31 02:39:00 +02:00
|
|
|
} {
|
|
|
|
coredomain_socket
|
|
|
|
core_data_file_type
|
|
|
|
unlabeled # used only by core domains
|
|
|
|
}:sock_file ~{ append getattr ioctl read write };
|
2018-01-24 16:01:13 +01:00
|
|
|
')
|
|
|
|
full_treble_only(`
|
2017-03-31 02:39:00 +02:00
|
|
|
neverallow {
|
|
|
|
appdomain
|
|
|
|
-coredomain
|
|
|
|
} {
|
|
|
|
coredomain_socket
|
|
|
|
unlabeled # used only by core domains
|
|
|
|
core_data_file_type
|
|
|
|
-app_data_file
|
2018-08-03 00:54:23 +02:00
|
|
|
-privapp_data_file
|
2017-05-01 22:01:44 +02:00
|
|
|
-pdx_endpoint_socket_type # used by VR layer
|
|
|
|
-pdx_channel_socket_type # used by VR layer
|
2017-03-31 02:39:00 +02:00
|
|
|
}:sock_file ~{ append getattr ioctl read write };
|
2018-01-24 16:01:13 +01:00
|
|
|
')
|
2017-03-31 02:39:00 +02:00
|
|
|
|
|
|
|
# Core domains are not permitted to create/open sockets owned by vendor domains
|
2018-01-24 16:01:13 +01:00
|
|
|
full_treble_only(`
|
2017-03-31 02:39:00 +02:00
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-init
|
|
|
|
-ueventd
|
|
|
|
-socket_between_core_and_vendor_violators
|
|
|
|
} {
|
|
|
|
file_type
|
|
|
|
dev_type
|
|
|
|
-coredomain_socket
|
|
|
|
-core_data_file_type
|
2020-11-12 19:08:18 +01:00
|
|
|
-app_data_file_type
|
2017-03-31 02:39:00 +02:00
|
|
|
-unlabeled
|
|
|
|
}:sock_file ~{ append getattr ioctl read write };
|
2017-03-25 00:07:35 +01:00
|
|
|
')
|
|
|
|
|
2017-11-10 19:49:23 +01:00
|
|
|
# On TREBLE devices, vendor and system components are only allowed to share
|
|
|
|
# files by passing open FDs over hwbinder. Ban all directory access and all file
|
|
|
|
# accesses other than what can be applied to an open FD such as
|
|
|
|
# ioctl/stat/read/write/append. This is enforced by segregating /data.
|
|
|
|
# Vendor domains may directly access file in /data/vendor by path, but may only
|
|
|
|
# access files outside of /data/vendor via an open FD passed over hwbinder.
|
|
|
|
# Likewise, core domains may only directly access files outside /data/vendor by
|
|
|
|
# path and files in /data/vendor by open FD.
|
|
|
|
full_treble_only(`
|
|
|
|
# only coredomains may only access core_data_file_type, particularly not
|
|
|
|
# /data/vendor
|
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-appdomain # TODO(b/34980020) remove exemption for appdomain
|
|
|
|
-data_between_core_and_vendor_violators
|
|
|
|
-init
|
2018-01-22 22:24:10 +01:00
|
|
|
-vold_prepare_subdirs
|
2017-11-10 19:49:23 +01:00
|
|
|
} {
|
|
|
|
data_file_type
|
|
|
|
-core_data_file_type
|
2020-11-12 19:08:18 +01:00
|
|
|
-app_data_file_type
|
2018-08-07 22:44:20 +02:00
|
|
|
}:file_class_set ~{ append getattr ioctl read write map };
|
2018-02-23 06:51:24 +01:00
|
|
|
')
|
|
|
|
full_treble_only(`
|
2017-11-10 19:49:23 +01:00
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-appdomain # TODO(b/34980020) remove exemption for appdomain
|
|
|
|
-data_between_core_and_vendor_violators
|
|
|
|
-init
|
2018-01-22 22:24:10 +01:00
|
|
|
-vold_prepare_subdirs
|
2017-11-10 19:49:23 +01:00
|
|
|
} {
|
|
|
|
data_file_type
|
|
|
|
-core_data_file_type
|
2020-11-12 19:08:18 +01:00
|
|
|
-app_data_file_type
|
2018-02-08 01:29:06 +01:00
|
|
|
# TODO(b/72998741) Remove exemption. Further restricted in a subsequent
|
|
|
|
# neverallow. Currently only getattr and search are allowed.
|
|
|
|
-vendor_data_file
|
2017-11-10 19:49:23 +01:00
|
|
|
}:dir *;
|
|
|
|
|
|
|
|
')
|
|
|
|
full_treble_only(`
|
|
|
|
# vendor domains may only access files in /data/vendor, never core_data_file_types
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-appdomain # TODO(b/34980020) remove exemption for appdomain
|
|
|
|
-coredomain
|
|
|
|
-data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up
|
2018-04-13 02:30:56 +02:00
|
|
|
-vendor_init
|
2017-11-10 19:49:23 +01:00
|
|
|
} {
|
|
|
|
core_data_file_type
|
|
|
|
# libc includes functions like mktime and localtime which attempt to access
|
2018-08-12 00:34:49 +02:00
|
|
|
# files in /data/misc/zoneinfo/tzdata and /system/usr/share/zoneinfo/tzdata.
|
|
|
|
# These functions are considered vndk-stable and thus must be allowed for
|
|
|
|
# all processes.
|
2017-11-10 19:49:23 +01:00
|
|
|
-zoneinfo_data_file
|
2019-06-14 00:05:15 +02:00
|
|
|
with_native_coverage(`-method_trace_data_file')
|
2018-08-07 22:44:20 +02:00
|
|
|
}:file_class_set ~{ append getattr ioctl read write map };
|
2018-04-13 02:30:56 +02:00
|
|
|
neverallow {
|
|
|
|
vendor_init
|
|
|
|
-data_between_core_and_vendor_violators
|
|
|
|
} {
|
|
|
|
core_data_file_type
|
|
|
|
-unencrypted_data_file
|
|
|
|
-zoneinfo_data_file
|
2019-06-14 00:05:15 +02:00
|
|
|
with_native_coverage(`-method_trace_data_file')
|
2018-08-07 22:44:20 +02:00
|
|
|
}:file_class_set ~{ append getattr ioctl read write map };
|
2018-04-13 02:30:56 +02:00
|
|
|
# vendor init needs to be able to read unencrypted_data_file to create directories with FBE.
|
|
|
|
# The vendor init binary lives on the system partition so there is not a concern with stability.
|
|
|
|
neverallow vendor_init unencrypted_data_file:file ~r_file_perms;
|
2017-11-10 19:49:23 +01:00
|
|
|
')
|
|
|
|
full_treble_only(`
|
|
|
|
# vendor domains may only access dirs in /data/vendor, never core_data_file_types
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-appdomain # TODO(b/34980020) remove exemption for appdomain
|
|
|
|
-coredomain
|
|
|
|
-data_between_core_and_vendor_violators
|
2018-04-13 02:30:56 +02:00
|
|
|
-vendor_init
|
|
|
|
} {
|
|
|
|
core_data_file_type
|
|
|
|
-system_data_file # default label for files on /data. Covered below...
|
2019-08-02 00:57:47 +02:00
|
|
|
-system_data_root_file
|
Restrict creating per-user encrypted directories
Creating a per-user encrypted directory such as /data/system_ce/0 and
the subdirectories in it too early has been a recurring bug. Typically,
individual services in system_server are to blame; system_server has
permission to create these directories, and it's easy to write
"mkdirs()" instead of "mkdir()". Such bugs are very bad, as they
prevent these directories from being encrypted, as encryption policies
can only be set on empty directories. Due to recent changes, a factory
reset is now forced in such cases, which helps detect these bugs;
however, it would be much better to prevent them in the first place.
This CL locks down the ability to create these directories to just vold
and init, or to just vold when possible. This is done by assigning new
types to the directories that contain these directories, and then only
allowing the needed domains to write to these parent directories. This
is similar to what https://r.android.com/1117297 did for /data itself.
Three new types are used instead of just one, since these directories
had three different types already (system_data_file, media_rw_data_file,
vendor_data_file), and this allows the policy to be a bit more precise.
A significant limitation is that /data/user/0 is currently being created
by init during early boot. Therefore, this CL doesn't help much for
/data/user/0, though it helps a lot for the other directories. As the
next step, I'll try to eliminate the /data/user/0 quirk. Anyway, this
CL is needed regardless of whether we're able to do that.
Test: Booted cuttlefish. Ran 'sm partition disk:253,32 private', then
created and deleted a user. Used 'ls -lZ' to check the relevant
SELinux labels on both internal and adoptable storage. Also did
similar tests on raven, with the addition of going through the
setup wizard and using an app that creates media files. No
relevant SELinux denials seen during any of this.
Bug: 156305599
Change-Id: I1fbdd180f56dd2fe4703763936f5850cef8ab0ba
2022-05-05 00:18:02 +02:00
|
|
|
-vendor_userdir_file
|
2018-04-13 02:30:56 +02:00
|
|
|
-vendor_data_file
|
|
|
|
-zoneinfo_data_file
|
2019-06-14 00:05:15 +02:00
|
|
|
with_native_coverage(`-method_trace_data_file')
|
2018-04-13 02:30:56 +02:00
|
|
|
}:dir *;
|
|
|
|
neverallow {
|
|
|
|
vendor_init
|
|
|
|
-data_between_core_and_vendor_violators
|
|
|
|
} {
|
|
|
|
core_data_file_type
|
|
|
|
-unencrypted_data_file
|
|
|
|
-system_data_file
|
2019-08-02 00:57:47 +02:00
|
|
|
-system_data_root_file
|
Restrict creating per-user encrypted directories
Creating a per-user encrypted directory such as /data/system_ce/0 and
the subdirectories in it too early has been a recurring bug. Typically,
individual services in system_server are to blame; system_server has
permission to create these directories, and it's easy to write
"mkdirs()" instead of "mkdir()". Such bugs are very bad, as they
prevent these directories from being encrypted, as encryption policies
can only be set on empty directories. Due to recent changes, a factory
reset is now forced in such cases, which helps detect these bugs;
however, it would be much better to prevent them in the first place.
This CL locks down the ability to create these directories to just vold
and init, or to just vold when possible. This is done by assigning new
types to the directories that contain these directories, and then only
allowing the needed domains to write to these parent directories. This
is similar to what https://r.android.com/1117297 did for /data itself.
Three new types are used instead of just one, since these directories
had three different types already (system_data_file, media_rw_data_file,
vendor_data_file), and this allows the policy to be a bit more precise.
A significant limitation is that /data/user/0 is currently being created
by init during early boot. Therefore, this CL doesn't help much for
/data/user/0, though it helps a lot for the other directories. As the
next step, I'll try to eliminate the /data/user/0 quirk. Anyway, this
CL is needed regardless of whether we're able to do that.
Test: Booted cuttlefish. Ran 'sm partition disk:253,32 private', then
created and deleted a user. Used 'ls -lZ' to check the relevant
SELinux labels on both internal and adoptable storage. Also did
similar tests on raven, with the addition of going through the
setup wizard and using an app that creates media files. No
relevant SELinux denials seen during any of this.
Bug: 156305599
Change-Id: I1fbdd180f56dd2fe4703763936f5850cef8ab0ba
2022-05-05 00:18:02 +02:00
|
|
|
-vendor_userdir_file
|
2018-04-13 02:30:56 +02:00
|
|
|
-vendor_data_file
|
|
|
|
-zoneinfo_data_file
|
2019-06-14 00:05:15 +02:00
|
|
|
with_native_coverage(`-method_trace_data_file')
|
2018-04-13 02:30:56 +02:00
|
|
|
}:dir *;
|
|
|
|
# vendor init needs to be able to read unencrypted_data_file to create directories with FBE.
|
|
|
|
# The vendor init binary lives on the system partition so there is not a concern with stability.
|
|
|
|
neverallow vendor_init unencrypted_data_file:dir ~search;
|
2017-11-10 19:49:23 +01:00
|
|
|
')
|
|
|
|
full_treble_only(`
|
|
|
|
# vendor domains may only access dirs in /data/vendor, never core_data_file_types
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-appdomain # TODO(b/34980020) remove exemption for appdomain
|
|
|
|
-coredomain
|
|
|
|
-data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up
|
|
|
|
} {
|
|
|
|
system_data_file # default label for files on /data. Covered below
|
|
|
|
}:dir ~{ getattr search };
|
|
|
|
')
|
|
|
|
|
2018-02-08 01:29:06 +01:00
|
|
|
full_treble_only(`
|
|
|
|
# coredomains may not access dirs in /data/vendor.
|
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up
|
|
|
|
-init
|
|
|
|
-vold # vold creates per-user storage for both system and vendor
|
|
|
|
-vold_prepare_subdirs
|
|
|
|
} {
|
|
|
|
vendor_data_file # default label for files on /data. Covered below
|
|
|
|
}:dir ~{ getattr search };
|
|
|
|
')
|
|
|
|
|
|
|
|
full_treble_only(`
|
|
|
|
# coredomains may not access dirs in /data/vendor.
|
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-data_between_core_and_vendor_violators # TODO(b/34980020) Remove once all violators have been cleaned up
|
|
|
|
-init
|
|
|
|
} {
|
|
|
|
vendor_data_file # default label for files on /data/vendor{,_ce,_de}.
|
2018-08-07 22:44:20 +02:00
|
|
|
}:file_class_set ~{ append getattr ioctl read write map };
|
2018-02-08 01:29:06 +01:00
|
|
|
')
|
|
|
|
|
2018-02-23 06:51:24 +01:00
|
|
|
full_treble_only(`
|
2017-04-13 22:06:00 +02:00
|
|
|
# Non-vendor domains are not allowed to file execute shell
|
|
|
|
# from vendor
|
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-init
|
2018-01-11 20:01:30 +01:00
|
|
|
-shell
|
2019-08-13 04:06:31 +02:00
|
|
|
-ueventd
|
2017-04-13 22:06:00 +02:00
|
|
|
} vendor_shell_exec:file { execute execute_no_trans };
|
2018-02-23 06:51:24 +01:00
|
|
|
')
|
2017-04-11 22:50:22 +02:00
|
|
|
|
2018-02-23 06:51:24 +01:00
|
|
|
full_treble_only(`
|
2017-04-11 22:50:22 +02:00
|
|
|
# Do not allow vendor components to execute files from system
|
2020-07-27 18:30:34 +02:00
|
|
|
# except for the ones allowed here.
|
2017-04-15 06:26:57 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-coredomain
|
|
|
|
-appdomain
|
|
|
|
-vendor_executes_system_violators
|
2017-09-28 23:34:36 +02:00
|
|
|
-vendor_init
|
2017-04-15 06:26:57 +02:00
|
|
|
} {
|
2018-10-19 22:26:24 +02:00
|
|
|
system_file_type
|
|
|
|
-system_lib_file
|
2018-08-12 00:34:49 +02:00
|
|
|
-system_linker_exec
|
2017-04-15 06:26:57 +02:00
|
|
|
-crash_dump_exec
|
|
|
|
-netutils_wrapper_exec
|
2018-10-14 23:38:20 +02:00
|
|
|
userdebug_or_eng(`-tcpdump_exec')
|
2017-04-15 06:26:57 +02:00
|
|
|
}:file { entrypoint execute execute_no_trans };
|
2018-02-23 06:51:24 +01:00
|
|
|
')
|
2018-01-16 18:56:44 +01:00
|
|
|
|
2020-04-29 20:29:54 +02:00
|
|
|
full_treble_only(`
|
|
|
|
# Do not allow coredomain to access entrypoint for files other
|
|
|
|
# than system_file_type and postinstall_file
|
|
|
|
neverallow coredomain {
|
|
|
|
file_type
|
|
|
|
-system_file_type
|
|
|
|
-postinstall_file
|
|
|
|
}:file entrypoint;
|
|
|
|
# Do not allow domains other than coredomain to access entrypoint
|
|
|
|
# for anything but vendor_file_type and init_exec for vendor_init.
|
|
|
|
neverallow { domain -coredomain } {
|
|
|
|
file_type
|
|
|
|
-vendor_file_type
|
|
|
|
-init_exec
|
|
|
|
}:file entrypoint;
|
|
|
|
')
|
|
|
|
|
2018-02-23 06:51:24 +01:00
|
|
|
full_treble_only(`
|
2018-01-16 18:56:44 +01:00
|
|
|
# Do not allow system components to execute files from vendor
|
2020-07-27 18:30:34 +02:00
|
|
|
# except for the ones allowed here.
|
2018-01-16 18:56:44 +01:00
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-init
|
2018-02-01 22:43:57 +01:00
|
|
|
-shell
|
2018-01-16 18:56:44 +01:00
|
|
|
-system_executes_vendor_violators
|
2019-08-13 04:06:31 +02:00
|
|
|
-ueventd
|
2018-01-16 18:56:44 +01:00
|
|
|
} {
|
|
|
|
vendor_file_type
|
|
|
|
-same_process_hal_file
|
|
|
|
-vndk_sp_file
|
|
|
|
-vendor_app_file
|
2021-01-25 13:57:56 +01:00
|
|
|
-vendor_public_framework_file
|
2018-04-30 23:38:21 +02:00
|
|
|
-vendor_public_lib_file
|
2018-01-16 18:56:44 +01:00
|
|
|
}:file execute;
|
2018-02-23 06:51:24 +01:00
|
|
|
')
|
2018-01-16 18:56:44 +01:00
|
|
|
|
2018-02-23 06:51:24 +01:00
|
|
|
full_treble_only(`
|
2018-01-16 18:56:44 +01:00
|
|
|
neverallow {
|
|
|
|
coredomain
|
2018-02-01 22:43:57 +01:00
|
|
|
-shell
|
2018-01-16 18:56:44 +01:00
|
|
|
-system_executes_vendor_violators
|
2018-08-07 01:25:36 +02:00
|
|
|
} {
|
|
|
|
vendor_file_type
|
|
|
|
-same_process_hal_file
|
|
|
|
}:file execute_no_trans;
|
2017-04-04 18:30:41 +02:00
|
|
|
')
|
|
|
|
|
2018-10-19 22:26:24 +02:00
|
|
|
full_treble_only(`
|
|
|
|
# Do not allow vendor components access to /system files except for the
|
2020-07-27 18:30:34 +02:00
|
|
|
# ones allowed here.
|
2018-10-19 22:26:24 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-appdomain
|
|
|
|
-coredomain
|
|
|
|
-vendor_executes_system_violators
|
|
|
|
# vendor_init needs access to init_exec for domain transition. vendor_init
|
|
|
|
# neverallows are covered in public/vendor_init.te
|
|
|
|
-vendor_init
|
|
|
|
} {
|
|
|
|
system_file_type
|
|
|
|
-crash_dump_exec
|
|
|
|
-file_contexts_file
|
|
|
|
-netutils_wrapper_exec
|
|
|
|
-property_contexts_file
|
2019-01-10 22:59:37 +01:00
|
|
|
-system_event_log_tags_file
|
2019-07-15 22:33:48 +02:00
|
|
|
-system_group_file
|
2018-10-19 22:26:24 +02:00
|
|
|
-system_lib_file
|
2018-10-22 22:05:03 +02:00
|
|
|
with_asan(`-system_asan_options_file')
|
2018-10-19 22:26:24 +02:00
|
|
|
-system_linker_exec
|
|
|
|
-system_linker_config_file
|
2019-07-15 22:33:48 +02:00
|
|
|
-system_passwd_file
|
2018-10-19 22:26:24 +02:00
|
|
|
-system_seccomp_policy_file
|
|
|
|
-system_security_cacerts_file
|
|
|
|
-system_zoneinfo_file
|
2020-11-21 03:57:36 +01:00
|
|
|
-task_profiles_api_file
|
2019-01-11 02:10:31 +01:00
|
|
|
-task_profiles_file
|
2018-10-19 22:26:24 +02:00
|
|
|
userdebug_or_eng(`-tcpdump_exec')
|
|
|
|
}:file *;
|
|
|
|
')
|
2018-08-12 00:34:49 +02:00
|
|
|
|
2015-03-09 18:13:13 +01:00
|
|
|
# Only system_server should be able to send commands via the zygote socket
|
|
|
|
neverallow { domain -zygote -system_server } zygote:unix_stream_socket connectto;
|
|
|
|
neverallow { domain -system_server } zygote_socket:sock_file write;
|
|
|
|
|
2018-11-05 11:39:15 +01:00
|
|
|
neverallow { domain -system_server -webview_zygote -app_zygote } webview_zygote:unix_stream_socket connectto;
|
2018-01-30 16:54:33 +01:00
|
|
|
neverallow { domain -system_server } webview_zygote:sock_file write;
|
2018-11-05 11:39:15 +01:00
|
|
|
neverallow { domain -system_server } app_zygote:sock_file write;
|
2016-09-21 23:01:50 +02:00
|
|
|
|
2022-03-15 17:35:16 +01:00
|
|
|
neverallow domain tombstoned_crash_socket:unix_stream_socket connectto;
|
2017-05-15 19:39:16 +02:00
|
|
|
|
2018-03-13 00:21:40 +01:00
|
|
|
# Never allow anyone except dumpstate, incidentd, or the system server to connect or write to
|
2017-05-15 19:39:16 +02:00
|
|
|
# the tombstoned intercept socket.
|
2018-03-13 00:21:40 +01:00
|
|
|
neverallow { domain -dumpstate -incidentd -system_server } tombstoned_intercept_socket:sock_file write;
|
|
|
|
neverallow { domain -dumpstate -incidentd -system_server } tombstoned_intercept_socket:unix_stream_socket connectto;
|
2016-10-19 23:39:30 +02:00
|
|
|
|
2020-12-18 01:50:40 +01:00
|
|
|
# Never allow anyone but system_server to read heapdumps in /data/system/heapdump.
|
|
|
|
neverallow { domain -init -system_server } heapdump_data_file:file read;
|
|
|
|
|
2015-02-11 00:53:17 +01:00
|
|
|
# Android does not support System V IPCs.
|
|
|
|
#
|
|
|
|
# The reason for this is due to the fact that, by design, they lead to global
|
|
|
|
# kernel resource leakage.
|
|
|
|
#
|
|
|
|
# For example, there is no way to automatically release a SysV semaphore
|
|
|
|
# allocated in the kernel when:
|
|
|
|
#
|
|
|
|
# - a buggy or malicious process exits
|
|
|
|
# - a non-buggy and non-malicious process crashes or is explicitly killed.
|
|
|
|
#
|
|
|
|
# Killing processes automatically to make room for new ones is an
|
|
|
|
# important part of Android's application lifecycle implementation. This means
|
|
|
|
# that, even assuming only non-buggy and non-malicious code, it is very likely
|
|
|
|
# that over time, the kernel global tables used to implement SysV IPCs will fill
|
|
|
|
# up.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * *:{ shm sem msg msgq } *;
|
2015-02-23 21:33:34 +01:00
|
|
|
|
|
|
|
# Do not mount on top of symlinks, fifos, or sockets.
|
|
|
|
# Feature parity with Chromium LSM.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * { file_type fs_type dev_type }:{ lnk_file fifo_file sock_file } mounton;
|
2015-03-14 20:40:21 +01:00
|
|
|
|
|
|
|
# Nobody should be able to execute su on user builds.
|
|
|
|
# On userdebug/eng builds, only dumpstate, shell, and
|
|
|
|
# su itself execute su.
|
|
|
|
neverallow { domain userdebug_or_eng(`-dumpstate -shell -su') } su_exec:file no_x_file_perms;
|
2015-03-24 14:03:52 +01:00
|
|
|
|
2018-08-07 17:13:05 +02:00
|
|
|
# Do not allow the introduction of new execmod rules. Text relocations
|
|
|
|
# and modification of executable pages are unsafe.
|
|
|
|
# The only exceptions are for NDK text relocations associated with
|
|
|
|
# https://code.google.com/p/android/issues/detail?id=23203
|
|
|
|
# which, long term, need to go away.
|
|
|
|
neverallow * {
|
|
|
|
file_type
|
|
|
|
-apk_data_file
|
|
|
|
-app_data_file
|
|
|
|
-asec_public_file
|
|
|
|
}:file execmod;
|
|
|
|
|
2015-06-22 18:42:59 +02:00
|
|
|
# Do not allow making the stack or heap executable.
|
|
|
|
# We would also like to minimize execmem but it seems to be
|
|
|
|
# required by some device-specific service domains.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * self:process { execstack execheap };
|
2015-06-22 18:42:59 +02:00
|
|
|
|
2018-08-08 00:14:34 +02:00
|
|
|
# Do not allow the introduction of new execmod rules. Text relocations
|
|
|
|
# and modification of executable pages are unsafe.
|
2019-04-02 22:01:10 +02:00
|
|
|
neverallow { domain -untrusted_app_25 -untrusted_app_27 } file_type:file execmod;
|
2015-04-14 20:21:46 +02:00
|
|
|
|
|
|
|
neverallow { domain -init } proc:{ file dir } mounton;
|
2015-05-01 16:09:43 +02:00
|
|
|
|
|
|
|
# Ensure that all types assigned to processes are included
|
|
|
|
# in the domain attribute, so that all allow and neverallow rules
|
|
|
|
# written on domain are applied to all processes.
|
|
|
|
# This is achieved by ensuring that it is impossible to transition
|
|
|
|
# from a domain to a non-domain type and vice versa.
|
2016-10-12 23:58:09 +02:00
|
|
|
# TODO - rework this: neverallow domain ~domain:process { transition dyntransition };
|
2015-05-01 16:09:43 +02:00
|
|
|
neverallow ~domain domain:process { transition dyntransition };
|
2015-05-13 05:32:29 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Only system_app and system_server should be creating or writing
|
|
|
|
# their files. The proper way to share files is to setup
|
|
|
|
# type transitions to a more specific type or assigning a type
|
|
|
|
# to its parent directory via a file_contexts entry.
|
|
|
|
# Example type transition:
|
|
|
|
# mydomain.te:file_type_auto_trans(mydomain, system_data_file, new_file_type)
|
|
|
|
#
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-system_server
|
|
|
|
-system_app
|
|
|
|
-init
|
2019-09-16 19:00:52 +02:00
|
|
|
-toolbox # TODO(b/141108496) We want to remove toolbox
|
2015-05-13 05:32:29 +02:00
|
|
|
-installd # for relabelfrom and unlink, check for this in explicit neverallow
|
2018-04-16 23:50:38 +02:00
|
|
|
-vold_prepare_subdirs # For unlink
|
2017-03-22 03:39:01 +01:00
|
|
|
with_asan(`-asan_extract')
|
2015-05-13 05:32:29 +02:00
|
|
|
} system_data_file:file no_w_file_perms;
|
|
|
|
# do not grant anything greater than r_file_perms and relabelfrom unlink
|
|
|
|
# to installd
|
|
|
|
neverallow installd system_data_file:file ~{ r_file_perms relabelfrom unlink };
|
2015-05-14 02:06:37 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Only these domains should transition to shell domain. This domain is
|
|
|
|
# permissible for the "shell user". If you need a process to exec a shell
|
|
|
|
# script with differing privilege, define a domain and set up a transition.
|
|
|
|
#
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-adbd
|
|
|
|
-init
|
|
|
|
-runas
|
|
|
|
-zygote
|
|
|
|
} shell:process { transition dyntransition };
|
2015-06-18 20:20:38 +02:00
|
|
|
|
2020-01-10 20:02:43 +01:00
|
|
|
# Only domains spawned from zygote, runas and simpleperf_app_runner may have
|
|
|
|
# the appdomain attribute. simpleperf is excluded as a domain transitioned to
|
|
|
|
# when running an app-scoped profiling session.
|
2019-01-11 00:34:08 +01:00
|
|
|
neverallow { domain -simpleperf_app_runner -runas -app_zygote -webview_zygote -zygote } {
|
2020-01-10 20:02:43 +01:00
|
|
|
appdomain -shell -simpleperf userdebug_or_eng(`-su')
|
2016-06-24 22:09:54 +02:00
|
|
|
}:process { transition dyntransition };
|
|
|
|
|
2015-06-18 20:20:38 +02:00
|
|
|
# Minimize read access to shell- or app-writable symlinks.
|
|
|
|
# This is to prevent malicious symlink attacks.
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-appdomain
|
|
|
|
-installd
|
2018-08-03 00:54:23 +02:00
|
|
|
} { app_data_file privapp_data_file }:lnk_file read;
|
2015-06-18 20:20:38 +02:00
|
|
|
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-shell
|
|
|
|
userdebug_or_eng(`-uncrypt')
|
|
|
|
-installd
|
|
|
|
} shell_data_file:lnk_file read;
|
2015-07-14 20:46:30 +02:00
|
|
|
|
2015-08-22 23:47:00 +02:00
|
|
|
# In addition to the symlink reading restrictions above, restrict
|
|
|
|
# write access to shell owned directories. The /data/local/tmp
|
2020-07-27 18:30:34 +02:00
|
|
|
# directory is untrustworthy, and non-allowed domains should
|
2015-08-22 23:47:00 +02:00
|
|
|
# not be trusting any content in those directories.
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-adbd
|
|
|
|
-dumpstate
|
|
|
|
-installd
|
|
|
|
-init
|
|
|
|
-shell
|
|
|
|
-vold
|
|
|
|
} shell_data_file:dir no_w_dir_perms;
|
|
|
|
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-adbd
|
|
|
|
-appdomain
|
|
|
|
-dumpstate
|
|
|
|
-init
|
|
|
|
-installd
|
2019-01-30 01:26:15 +01:00
|
|
|
-simpleperf_app_runner
|
2015-08-22 23:47:00 +02:00
|
|
|
-system_server # why?
|
|
|
|
userdebug_or_eng(`-uncrypt')
|
|
|
|
} shell_data_file:dir { open search };
|
|
|
|
|
2017-04-14 22:50:34 +02:00
|
|
|
# servicemanager and vndservicemanager are the only processes which handle the
|
|
|
|
# service_manager list request
|
|
|
|
neverallow * ~{
|
|
|
|
servicemanager
|
|
|
|
vndservicemanager
|
|
|
|
}:service_manager list;
|
|
|
|
|
|
|
|
# hwservicemanager is the only process which handles hw list requests
|
|
|
|
neverallow * ~{
|
|
|
|
hwservicemanager
|
|
|
|
}:hwservice_manager list;
|
2015-07-14 20:46:30 +02:00
|
|
|
|
|
|
|
# only service_manager_types can be added to service_manager
|
2016-10-12 23:58:09 +02:00
|
|
|
# TODO - rework this: neverallow * ~service_manager_type:service_manager { add find };
|
2015-09-22 01:22:21 +02:00
|
|
|
|
2015-09-30 02:01:03 +02:00
|
|
|
# Prevent assigning non property types to properties
|
2017-01-27 05:01:50 +01:00
|
|
|
# TODO - rework this: neverallow * ~property_type:property_service set;
|
2015-09-15 05:45:30 +02:00
|
|
|
|
|
|
|
# Domain types should never be assigned to any files other
|
|
|
|
# than the /proc/pid files associated with a process. The
|
|
|
|
# executable file used to enter a domain should be labeled
|
|
|
|
# with its own _exec type, not with the domain type.
|
|
|
|
# Conventionally, this looks something like:
|
|
|
|
# $ cat mydaemon.te
|
|
|
|
# type mydaemon, domain;
|
|
|
|
# type mydaemon_exec, exec_type, file_type;
|
|
|
|
# init_daemon_domain(mydaemon)
|
|
|
|
# $ grep mydaemon file_contexts
|
|
|
|
# /system/bin/mydaemon -- u:object_r:mydaemon_exec:s0
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * domain:file { execute execute_no_trans entrypoint };
|
2015-12-18 01:38:21 +01:00
|
|
|
|
|
|
|
# Do not allow access to the generic debugfs label. This is too broad.
|
|
|
|
# Instead, if access to part of debugfs is desired, it should have a
|
|
|
|
# more specific label.
|
2018-11-16 20:23:54 +01:00
|
|
|
# TODO: fix dumpstate
|
2019-02-04 19:07:15 +01:00
|
|
|
neverallow { domain -init -vendor_init -dumpstate } debugfs:{ file lnk_file } no_rw_file_perms;
|
|
|
|
|
|
|
|
# Do not allow executable files in debugfs.
|
|
|
|
neverallow domain debugfs_type:file { execute execute_no_trans };
|
2015-12-02 05:43:46 +01:00
|
|
|
|
2020-05-28 15:04:48 +02:00
|
|
|
# Don't allow access to the FUSE control filesystem, except to vold and init's
|
|
|
|
neverallow { domain -vold -init -vendor_init } fusectlfs:file no_rw_file_perms;
|
|
|
|
|
2016-02-01 20:28:39 +01:00
|
|
|
# Profiles contain untrusted data and profman parses that. We should only run
|
|
|
|
# in from installd forked processes.
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-installd
|
|
|
|
-profman
|
|
|
|
} profman_exec:file no_x_file_perms;
|
2016-04-07 20:26:34 +02:00
|
|
|
|
|
|
|
# Enforce restrictions on kernel module origin.
|
|
|
|
# Do not allow kernel module loading except from system,
|
2022-02-10 01:35:54 +01:00
|
|
|
# vendor, boot, and system_dlkm partitions.
|
|
|
|
# TODO(b/218951883): Remove usage of system and rootfs as origin
|
|
|
|
neverallow * ~{ system_file_type vendor_file_type rootfs system_dlkm_file_type }:system module_load;
|
2016-10-27 21:45:20 +02:00
|
|
|
|
2017-11-21 21:56:30 +01:00
|
|
|
# Only allow filesystem caps to be set at build time. Runtime changes
|
|
|
|
# to filesystem capabilities are not permitted.
|
|
|
|
neverallow * self:global_capability_class_set setfcap;
|
2016-10-19 23:39:30 +02:00
|
|
|
|
|
|
|
# Enforce AT_SECURE for executing crash_dump.
|
|
|
|
neverallow domain crash_dump:process noatsecure;
|
2017-04-22 02:06:43 +02:00
|
|
|
|
|
|
|
# Do not permit non-core domains to register HwBinder services which are
|
|
|
|
# guaranteed to be provided by core domains only.
|
|
|
|
neverallow ~coredomain coredomain_hwservice:hwservice_manager add;
|
|
|
|
|
|
|
|
# Do not permit the registeration of HwBinder services which are guaranteed to
|
|
|
|
# be passthrough only (i.e., run in the process of their clients instead of a
|
|
|
|
# separate server process).
|
|
|
|
neverallow * same_process_hwservice:hwservice_manager add;
|
2017-12-18 19:15:06 +01:00
|
|
|
|
2018-04-06 12:59:38 +02:00
|
|
|
# If an already existing file is opened with O_CREAT, the kernel might generate
|
2018-03-21 18:43:30 +01:00
|
|
|
# a false report of a create denial. Silence these denials and make sure that
|
|
|
|
# inappropriate permissions are not granted.
|
2018-04-06 12:59:38 +02:00
|
|
|
|
|
|
|
# These filesystems don't allow files or directories to be created, so the permission
|
|
|
|
# to do so should never be granted.
|
2018-03-21 18:43:30 +01:00
|
|
|
neverallow domain {
|
|
|
|
proc_type
|
|
|
|
sysfs_type
|
|
|
|
}:dir { add_name create link remove_name rename reparent rmdir write };
|
|
|
|
|
2018-04-06 12:59:38 +02:00
|
|
|
# cgroupfs directories can be created, but not files within them.
|
|
|
|
neverallow domain cgroup:file create;
|
2021-02-12 00:18:11 +01:00
|
|
|
neverallow domain cgroup_v2:file create;
|
2018-03-26 18:06:23 +02:00
|
|
|
|
2018-03-21 18:43:30 +01:00
|
|
|
dontaudit domain proc_type:dir write;
|
|
|
|
dontaudit domain sysfs_type:dir write;
|
2018-04-06 12:59:38 +02:00
|
|
|
dontaudit domain cgroup:file create;
|
2021-02-12 00:18:11 +01:00
|
|
|
dontaudit domain cgroup_v2:file create;
|
2018-03-28 16:07:59 +02:00
|
|
|
|
|
|
|
# These are only needed in permissive mode - in enforcing mode the
|
|
|
|
# directory write check fails and so these are never attempted.
|
|
|
|
userdebug_or_eng(`
|
|
|
|
dontaudit domain proc_type:dir add_name;
|
|
|
|
dontaudit domain sysfs_type:dir add_name;
|
|
|
|
dontaudit domain proc_type:file create;
|
|
|
|
dontaudit domain sysfs_type:file create;
|
|
|
|
')
|
2018-04-11 05:49:45 +02:00
|
|
|
|
|
|
|
# Platform must not have access to /mnt/vendor.
|
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-init
|
2018-06-13 13:50:34 +02:00
|
|
|
-ueventd
|
2018-07-13 17:34:48 +02:00
|
|
|
-vold
|
2018-09-18 04:17:41 +02:00
|
|
|
-system_writes_mnt_vendor_violators
|
2018-04-11 05:49:45 +02:00
|
|
|
} mnt_vendor_file:dir *;
|
2018-04-30 23:38:21 +02:00
|
|
|
|
|
|
|
# Only apps are allowed access to vendor public libraries.
|
|
|
|
full_treble_only(`
|
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-appdomain
|
2021-01-25 13:57:56 +01:00
|
|
|
} {vendor_public_framework_file vendor_public_lib_file}:file { execute execute_no_trans };
|
2018-04-30 23:38:21 +02:00
|
|
|
')
|
2018-06-29 04:10:00 +02:00
|
|
|
|
|
|
|
# Vendor domian must not have access to /mnt/product.
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-coredomain
|
|
|
|
} mnt_product_file:dir *;
|
2018-06-29 23:58:38 +02:00
|
|
|
|
2021-10-20 22:45:48 +02:00
|
|
|
# Platform must not have access to sysfs_batteryinfo, but should do it via health HAL
|
2018-06-29 23:58:38 +02:00
|
|
|
full_treble_only(`
|
|
|
|
neverallow {
|
|
|
|
coredomain
|
|
|
|
-shell
|
2021-10-08 18:30:03 +02:00
|
|
|
# For access to block device information under /sys/class/block.
|
|
|
|
-apexd
|
2021-10-13 19:56:57 +02:00
|
|
|
# Read sysfs block device information.
|
|
|
|
-init
|
2018-06-29 23:58:38 +02:00
|
|
|
# Generate uevents for health info
|
|
|
|
-ueventd
|
|
|
|
# Recovery uses health HAL passthrough implementation.
|
|
|
|
-recovery
|
|
|
|
# Charger uses health HAL passthrough implementation.
|
|
|
|
-charger
|
|
|
|
# TODO(b/110891300): remove this exception
|
|
|
|
-incidentd
|
|
|
|
} sysfs_batteryinfo:file { open read };
|
|
|
|
')
|
2018-09-20 21:07:44 +02:00
|
|
|
|
|
|
|
neverallow {
|
|
|
|
domain
|
2019-04-30 14:09:28 +02:00
|
|
|
-hal_codec2_server
|
2018-09-20 21:07:44 +02:00
|
|
|
-hal_omx_server
|
|
|
|
} hal_codec2_hwservice:hwservice_manager add;
|
2019-10-16 00:27:28 +02:00
|
|
|
|
|
|
|
# Only apps targetting < Q are allowed to open /dev/ashmem directly.
|
|
|
|
# Apps must use ASharedMemory NDK API. Native code must use libcutils API.
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-ephemeral_app # We don't distinguish ephemeral apps based on target API.
|
|
|
|
-untrusted_app_25
|
|
|
|
-untrusted_app_27
|
|
|
|
} ashmem_device:chr_file open;
|
2020-11-05 13:54:52 +01:00
|
|
|
|
|
|
|
neverallow { domain -traced_probes -init -vendor_init } debugfs_tracing_printk_formats:file *;
|
2021-03-17 07:57:19 +01:00
|
|
|
|
|
|
|
# Linux lockdown "integrity" level is enforced for user builds.
|
|
|
|
neverallow { domain userdebug_or_eng(`-domain') } self:lockdown integrity;
|