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;
|
2016-01-22 18:29:00 +01:00
|
|
|
allow domain proc_net: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 };
|
2016-04-15 19:54:40 +02:00
|
|
|
allowxperm domain domain:{ unix_dgram_socket unix_stream_socket } ioctl unpriv_unix_sock_ioctls;
|
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(`
|
|
|
|
# Same as adbd rules above, except allow su to do the same thing
|
|
|
|
allow domain su:unix_stream_socket connectto;
|
|
|
|
allow domain su:fd use;
|
|
|
|
allow domain su:unix_stream_socket { getattr getopt read write shutdown };
|
|
|
|
|
2016-03-02 14:57:34 +01:00
|
|
|
allow { domain -init } su:binder { call transfer };
|
|
|
|
allow { domain -init } su:fd use;
|
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
|
|
|
')
|
|
|
|
|
2013-07-15 20:41:24 +02:00
|
|
|
###
|
|
|
|
### Talk to debuggerd.
|
|
|
|
###
|
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 debuggerd:process sigchld;
|
|
|
|
allow domain debuggerd:unix_stream_socket connectto;
|
|
|
|
|
|
|
|
# Root fs.
|
2015-11-06 00:24:22 +01:00
|
|
|
allow domain rootfs:dir search;
|
|
|
|
allow domain rootfs:lnk_file 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
|
|
|
|
|
|
|
# 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;
|
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;
|
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 ashmem_device:chr_file rw_file_perms;
|
|
|
|
allow domain binder_device:chr_file rw_file_perms;
|
|
|
|
allow domain ptmx_device:chr_file rw_file_perms;
|
|
|
|
allow domain alarm_device:chr_file r_file_perms;
|
2013-09-10 20:13:15 +02:00
|
|
|
allow domain urandom_device:chr_file rw_file_perms;
|
|
|
|
allow domain random_device:chr_file rw_file_perms;
|
2015-12-02 01:58:27 +01:00
|
|
|
allow domain properties_device:dir r_dir_perms;
|
|
|
|
allow domain properties_serial:file r_file_perms;
|
|
|
|
|
2015-12-08 23:45:50 +01:00
|
|
|
# For now, everyone can access core property files
|
|
|
|
# Device specific properties are not granted by default
|
|
|
|
get_prop(domain, core_property_type)
|
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;
|
|
|
|
allow domain property_contexts:file r_file_perms;
|
|
|
|
|
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)
|
|
|
|
|
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
|
|
|
# System file accesses.
|
2015-11-25 18:31:40 +01:00
|
|
|
allow domain system_file:dir { search getattr };
|
2015-11-06 00:24:22 +01:00
|
|
|
allow domain system_file:file { execute read open getattr };
|
|
|
|
allow domain system_file:lnk_file 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
|
|
|
|
2016-01-08 00:54:56 +01:00
|
|
|
# read any sysfs symlinks
|
|
|
|
allow domain sysfs:lnk_file read;
|
|
|
|
|
2015-11-28 04:18:17 +01:00
|
|
|
# libc references /data/misc/zoneinfo for timezone related information
|
|
|
|
r_dir_file(domain, zoneinfo_data_file)
|
|
|
|
|
2015-12-10 20:10:20 +01:00
|
|
|
# Lots of processes access current CPU information
|
|
|
|
r_dir_file(domain, sysfs_devices_system_cpu)
|
|
|
|
|
2015-11-06 00:24:22 +01:00
|
|
|
# files under /data.
|
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 system_data_file:dir { search getattr };
|
2015-11-25 18:31:40 +01:00
|
|
|
allow domain system_data_file:lnk_file read;
|
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;
|
|
|
|
|
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
|
|
|
|
2016-01-27 03:56:52 +01:00
|
|
|
# For /acct/uid/*/tasks.
|
|
|
|
allow domain cgroup:dir { search write };
|
|
|
|
allow domain cgroup:file w_file_perms;
|
|
|
|
|
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;
|
2015-12-08 02:02:31 +01:00
|
|
|
allow domain debugfs_trace_marker:file w_file_perms;
|
|
|
|
|
2016-01-22 00:04:10 +01:00
|
|
|
# Filesystem access.
|
|
|
|
allow domain fs_type:filesystem getattr;
|
|
|
|
allow domain fs_type:dir getattr;
|
|
|
|
|
2013-07-16 02:10:35 +02:00
|
|
|
###
|
|
|
|
### neverallow rules
|
|
|
|
###
|
|
|
|
|
2014-10-21 16:09:33 +02:00
|
|
|
# Do not allow any domain other than init or recovery to create unlabeled files.
|
|
|
|
neverallow { domain -init -recovery } unlabeled:dir_file_class_set create;
|
2014-05-29 22:37:13 +02:00
|
|
|
|
2014-02-10 22:31:04 +01:00
|
|
|
# Limit ability to ptrace or read sensitive /proc/pid files of processes
|
|
|
|
# with other UIDs to these whitelisted domains.
|
2015-03-19 17:35:31 +01:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-debuggerd
|
|
|
|
-vold
|
|
|
|
-dumpstate
|
|
|
|
-system_server
|
2015-05-06 00:11:44 +02:00
|
|
|
userdebug_or_eng(`-perfprofd')
|
2015-03-19 17:35:31 +01:00
|
|
|
} self:capability sys_ptrace;
|
2014-02-10 22:31:04 +01:00
|
|
|
|
2014-07-10 05:04:59 +02:00
|
|
|
# Limit device node creation to these whitelisted 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
|
|
|
|
} self:capability mknod;
|
2014-07-10 05:04:59 +02:00
|
|
|
|
2016-04-15 18:18:55 +02:00
|
|
|
# Limit raw I/O to these whitelisted domains. Do not apply to debug builds.
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
userdebug_or_eng(`-domain')
|
|
|
|
-kernel
|
|
|
|
-init
|
|
|
|
-recovery
|
|
|
|
-ueventd
|
|
|
|
-healthd
|
|
|
|
-uncrypt
|
|
|
|
-tee
|
|
|
|
} self:capability sys_rawio;
|
2014-02-10 22:31:04 +01: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.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * self:capability2 mac_override;
|
2014-02-10 22:31:04 +01:00
|
|
|
|
|
|
|
# Only recovery needs mac_admin to set contexts not defined in current policy.
|
2014-01-30 19:23:08 +01:00
|
|
|
neverallow { domain -recovery } self:capability2 mac_admin;
|
|
|
|
|
2015-08-03 17:28:26 +02:00
|
|
|
# Only init should be able to load SELinux policies.
|
2013-12-06 14:05:53 +01:00
|
|
|
# The first load technically occurs while still in the kernel domain,
|
|
|
|
# but this does not trigger a denial since there is no policy yet.
|
2015-08-03 17:28:26 +02:00
|
|
|
# Policy reload requires allowing this to the init domain.
|
|
|
|
neverallow { domain -init } kernel:security load_policy;
|
2013-12-06 14:05:53 +01:00
|
|
|
|
2014-05-30 16:25:00 +02:00
|
|
|
# Only init and the system_server can set selinux.reload_policy 1
|
|
|
|
# to trigger a policy reload.
|
|
|
|
neverallow { domain -init -system_server } security_prop:property_service set;
|
|
|
|
|
|
|
|
# Only init and system_server can write to /data/security, where runtime
|
|
|
|
# policy updates live.
|
|
|
|
# Only init can relabel /data/security (for init.rc restorecon_recursive /data).
|
|
|
|
neverallow { domain -init } security_file:{ dir file lnk_file } { relabelfrom relabelto };
|
|
|
|
# Only init and system_server can create/setattr directories with this type.
|
|
|
|
# init is for init.rc mkdir /data/security.
|
|
|
|
# system_server is for creating subdirectories under /data/security.
|
|
|
|
neverallow { domain -init -system_server } security_file:dir { create setattr };
|
|
|
|
# Only system_server can create subdirectories and files under /data/security.
|
|
|
|
neverallow { domain -system_server } security_file:dir { rename write add_name remove_name rmdir };
|
|
|
|
neverallow { domain -system_server } security_file:file { create setattr write append unlink link rename };
|
|
|
|
neverallow { domain -system_server } security_file:lnk_file { create setattr unlink rename };
|
|
|
|
|
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;
|
|
|
|
|
2013-10-06 21:36:11 +02:00
|
|
|
# Only init, ueventd and system_server should be able to access HW RNG
|
2014-10-21 16:09:33 +02:00
|
|
|
neverallow { domain -init -system_server -ueventd } hw_random_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
|
|
|
|
|
|
|
# Ensure that nothing in userspace can access /dev/mem or /dev/kmem
|
|
|
|
neverallow { domain -kernel -ueventd -init } kmem_device:chr_file *;
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * kmem_device:chr_file ~{ create relabelto unlink setattr };
|
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 };
|
|
|
|
neverallow { domain -init } proc_security:file { append write };
|
2013-12-09 18:49:47 +01:00
|
|
|
|
|
|
|
# No domain should be allowed to ptrace init.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * init:process ptrace;
|
2014-01-04 05:44:07 +01:00
|
|
|
|
2014-08-22 01:26:23 +02:00
|
|
|
# Init can't do anything with binder calls. If this neverallow rule is being
|
2014-01-04 05:44:07 +01:00
|
|
|
# triggered, it's probably due to a service with no SELinux domain.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * 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
|
2015-10-07 01:05:27 +02:00
|
|
|
neverallow { domain -kernel -init -recovery -uncrypt } block_device:blk_file { open read write };
|
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.
|
2014-10-21 16:09:33 +02:00
|
|
|
# init is exempt from this as there are character devices that only it uses.
|
|
|
|
# ueventd is exempt from this, as it is managing these devices.
|
2015-03-02 22:37:18 +01:00
|
|
|
neverallow { domain -init -ueventd } device:chr_file { open read write };
|
2014-02-10 19:29:38 +01:00
|
|
|
|
|
|
|
# Limit what domains can mount filesystems or change their mount flags.
|
|
|
|
# sdcard_type / vfat is exempt as a larger set of domains need
|
|
|
|
# this capability, including device-specific domains.
|
2016-03-02 01:14:45 +01:00
|
|
|
neverallow { domain -kernel -init -recovery -vold -zygote -update_engine } { fs_type -sdcard_type }:filesystem { mount remount relabelfrom relabelto };
|
2014-05-24 01:08:23 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Assert that, to the extent possible, we're not loading executable content from
|
2014-07-21 16:21:20 +02:00
|
|
|
# outside the rootfs or /system partition except for a few whitelisted domains.
|
2014-05-24 01:08:23 +02:00
|
|
|
#
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-appdomain
|
2015-11-25 18:41:05 +01:00
|
|
|
-autoplay_app
|
2014-05-24 01:08:23 +02:00
|
|
|
-dumpstate
|
2014-06-11 13:10:09 +02:00
|
|
|
-shell
|
2014-05-24 01:08:23 +02:00
|
|
|
userdebug_or_eng(`-su')
|
|
|
|
-system_server
|
|
|
|
-zygote
|
2016-03-02 01:14:45 +01:00
|
|
|
} { file_type -system_file -exec_type -postinstall_file }:file execute;
|
2014-07-21 16:21:20 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-appdomain # for oemfs
|
|
|
|
-recovery # for /tmp/update_binary in tmpfs
|
|
|
|
} { fs_type -rootfs }:file execute;
|
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
|
|
|
|
2015-06-22 16:26:26 +02:00
|
|
|
# Protect most domains from executing arbitrary content from /data.
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-untrusted_app
|
2015-10-05 18:15:04 +02:00
|
|
|
-priv_app
|
2015-06-22 16:26:26 +02:00
|
|
|
-shell
|
|
|
|
} {
|
|
|
|
data_file_type
|
|
|
|
-dalvikcache_data_file
|
|
|
|
-system_data_file # shared libs in apks
|
|
|
|
-apk_data_file
|
|
|
|
}:file no_x_file_perms;
|
|
|
|
|
2015-10-29 00:45:58 +01:00
|
|
|
neverallow { domain userdebug_or_eng(`-shell') } nativetest_data_file:file no_x_file_perms;
|
|
|
|
|
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;
|
|
|
|
neverallow { domain -init } property_data_file:file no_w_file_perms;
|
2016-03-25 21:59:55 +01:00
|
|
|
neverallow { domain -init } property_type:file no_w_file_perms;
|
|
|
|
neverallow { domain -init } properties_device:file no_w_file_perms;
|
|
|
|
neverallow { domain -init } properties_serial:file no_w_file_perms;
|
2014-05-20 20:09:16 +02:00
|
|
|
|
|
|
|
# Only recovery should be doing writes to /system
|
|
|
|
neverallow { domain -recovery } { system_file exec_type }:dir_file_class_set
|
2015-04-24 20:38:10 +02:00
|
|
|
{ create write setattr relabelfrom append unlink link rename };
|
|
|
|
neverallow { domain -recovery -kernel } { system_file 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-07-24 06:01:13 +02:00
|
|
|
neverallow { domain -init } system_file: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.
|
|
|
|
neverallow { domain -recovery } contextmount_type:dir_file_class_set
|
|
|
|
{ create write setattr relabelfrom relabelto append unlink link rename };
|
2014-07-07 18:27:53 +02:00
|
|
|
|
|
|
|
# Do not allow service_manager add for default_android_service.
|
|
|
|
# Instead domains should use a more specific type such as
|
|
|
|
# system_app_service rather than the generic type.
|
|
|
|
# New service_types are defined in service.te and new mappings
|
|
|
|
# from service name to service_type are defined in service_contexts.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * default_android_service:service_manager add;
|
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.
|
|
|
|
neverallow { domain -init } default_prop:property_service set;
|
2016-02-04 19:55:43 +01:00
|
|
|
neverallow { domain -init } mmc_prop:property_service set;
|
2014-09-08 22:11:01 +02:00
|
|
|
|
|
|
|
neverallow { domain -init -recovery -system_server } frp_block_device:blk_file rw_file_perms;
|
2014-09-30 18:53:12 +02:00
|
|
|
|
2015-10-05 23:04:39 +02:00
|
|
|
# No domain other than recovery and update_engine can write to system partition(s).
|
|
|
|
neverallow { domain -recovery -update_engine } system_block_device:blk_file write;
|
2014-09-30 18:53:12 +02:00
|
|
|
|
|
|
|
# No domains other than install_recovery or recovery can write to recovery.
|
|
|
|
neverallow { domain -install_recovery -recovery } recovery_block_device:blk_file write;
|
2014-12-10 22:50:39 +01:00
|
|
|
|
2016-04-15 02:23:10 +02:00
|
|
|
# No domains other than a select few can access the misc_block_device. This
|
|
|
|
# block device is reserved for OTA use.
|
|
|
|
# Do not assert this rule on userdebug/eng builds, due to some devices using
|
|
|
|
# this partition for testing purposes.
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
userdebug_or_eng(`-domain') # exclude debuggable builds
|
|
|
|
-init
|
|
|
|
-uncrypt
|
|
|
|
-update_engine
|
|
|
|
-vold
|
|
|
|
-recovery
|
|
|
|
} misc_block_device:blk_file { append link relabelfrom rename write open read ioctl lock };
|
|
|
|
|
2014-12-10 22:50:39 +01:00
|
|
|
# Only servicemanager should be able to register with binder as the context manager
|
|
|
|
neverallow { domain -servicemanager } *:binder set_context_mgr;
|
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
|
|
|
|
|
|
|
# Only authorized processes should be writing to files in /data/dalvik-cache
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-init # TODO: limit init to relabelfrom for files
|
|
|
|
-zygote
|
|
|
|
-installd
|
2016-03-30 00:08:20 +02:00
|
|
|
-postinstall_dexopt
|
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
|
|
|
-dex2oat
|
|
|
|
} dalvikcache_data_file:file no_w_file_perms;
|
2015-02-11 00:53:17 +01:00
|
|
|
|
2015-06-16 15:12:54 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-init
|
|
|
|
-installd
|
2016-03-30 00:08:20 +02:00
|
|
|
-postinstall_dexopt
|
2015-06-16 15:12:54 +02:00
|
|
|
-dex2oat
|
|
|
|
-zygote
|
|
|
|
} dalvikcache_data_file:dir no_w_dir_perms;
|
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
|
|
|
# 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.
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * {
|
2015-03-24 14:03:52 +01:00
|
|
|
file_type
|
|
|
|
-system_data_file
|
|
|
|
-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
|
|
|
|
2015-10-28 01:15:34 +01:00
|
|
|
# prohibit non-zygote spawned processes from using shared libraries
|
2015-04-02 02:41:41 +02:00
|
|
|
# with text relocations. b/20013628 .
|
2015-10-28 01:15:34 +01:00
|
|
|
neverallow { domain -appdomain } 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.
|
|
|
|
neverallow domain ~domain:process { transition dyntransition };
|
|
|
|
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
|
|
|
|
-installd # for relabelfrom and unlink, check for this in explicit neverallow
|
|
|
|
} 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
|
|
|
|
|
|
|
# Minimize read access to shell- or app-writable symlinks.
|
|
|
|
# This is to prevent malicious symlink attacks.
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-appdomain
|
|
|
|
-installd
|
|
|
|
-uncrypt # TODO: see if we can remove
|
|
|
|
} app_data_file:lnk_file read;
|
|
|
|
|
|
|
|
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
|
|
|
|
# directory is untrustworthy, and non-whitelisted domains should
|
|
|
|
# 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
|
|
|
|
-system_server # why?
|
|
|
|
userdebug_or_eng(`-uncrypt')
|
|
|
|
} shell_data_file:dir { open search };
|
|
|
|
|
|
|
|
# Same as above for /data/local/tmp files. We allow shell files
|
|
|
|
# to be passed around by file descriptor, but not directly opened.
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-adbd
|
|
|
|
-appdomain
|
|
|
|
-dumpstate
|
|
|
|
-installd
|
2015-10-08 01:44:15 +02:00
|
|
|
userdebug_or_eng(`-uncrypt')
|
2015-08-22 23:47:00 +02:00
|
|
|
} shell_data_file:file open;
|
|
|
|
|
2015-07-14 20:46:30 +02:00
|
|
|
# servicemanager is the only process which handles list request
|
2016-02-05 23:48:03 +01:00
|
|
|
neverallow * ~servicemanager:service_manager list;
|
2015-07-14 20:46:30 +02:00
|
|
|
|
|
|
|
# only service_manager_types can be added to service_manager
|
2016-02-05 23:48:03 +01:00
|
|
|
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
|
2016-02-05 23:48:03 +01:00
|
|
|
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.
|
|
|
|
# TODO: fix system_server and dumpstate
|
|
|
|
neverallow { domain -init -system_server -dumpstate } debugfs:file no_rw_file_perms;
|
2015-12-02 05:43:46 +01:00
|
|
|
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-init
|
|
|
|
-recovery
|
|
|
|
-sdcardd
|
|
|
|
-vold
|
|
|
|
} fuse_device:chr_file open;
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-dumpstate
|
|
|
|
-init
|
|
|
|
-priv_app
|
|
|
|
-recovery
|
|
|
|
-sdcardd
|
|
|
|
-system_server
|
|
|
|
-ueventd
|
|
|
|
-vold
|
|
|
|
} fuse_device:chr_file *;
|
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,
|
|
|
|
# vendor, and boot partitions.
|
|
|
|
neverallow * ~{ system_file rootfs }:system module_load;
|