Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 1 | # network manager |
| 2 | type netd, domain; |
| 3 | type netd_exec, exec_type, file_type; |
| 4 | |
| 5 | init_daemon_domain(netd) |
Nick Kralevich | bc19050 | 2013-12-15 19:04:09 -0800 | [diff] [blame] | 6 | net_domain(netd) |
| 7 | |
Stephen Smalley | d581b81 | 2014-02-24 13:00:59 -0500 | [diff] [blame] | 8 | allow netd self:capability { net_admin net_raw kill }; |
| 9 | # Note: fsetid is deliberately not included above. fsetid checks are |
| 10 | # triggered by chmod on a directory or file owned by a group other |
| 11 | # than one of the groups assigned to the current process to see if |
| 12 | # the setgid bit should be cleared, regardless of whether the setgid |
| 13 | # bit was even set. We do not appear to truly need this capability |
| 14 | # for netd to operate. Uncomment the dontaudit rule below after |
| 15 | # sufficient testing of the fsetid removal. |
| 16 | # dontaudit netd self:capability fsetid; |
| 17 | |
Stephen Smalley | 1601132 | 2014-02-24 15:06:11 -0500 | [diff] [blame] | 18 | allow netd self:netlink_kobject_uevent_socket create_socket_perms; |
| 19 | allow netd self:netlink_route_socket nlmsg_write; |
| 20 | allow netd self:netlink_nflog_socket create_socket_perms; |
Nick Kralevich | dbd28d9 | 2013-06-27 15:11:02 -0700 | [diff] [blame] | 21 | allow netd shell_exec:file rx_file_perms; |
| 22 | allow netd system_file:file x_file_perms; |
| 23 | allow netd devpts:chr_file rw_file_perms; |
| 24 | |
| 25 | # For /proc/sys/net/ipv[46]/route/flush. |
Robert Craig | 529fcbe | 2014-01-07 13:46:56 -0500 | [diff] [blame] | 26 | allow netd proc_net:file write; |
Nick Kralevich | dbd28d9 | 2013-06-27 15:11:02 -0700 | [diff] [blame] | 27 | |
| 28 | # For /sys/modules/bcmdhd/parameters/firmware_path |
| 29 | # XXX Split into its own type. |
| 30 | allow netd sysfs:file write; |
| 31 | |
| 32 | # Set dhcp lease for PAN connection |
| 33 | unix_socket_connect(netd, property, init) |
Stephen Smalley | fee4915 | 2014-06-19 10:27:02 -0400 | [diff] [blame] | 34 | allow netd dhcp_prop:property_service set; |
Nick Kralevich | dbd28d9 | 2013-06-27 15:11:02 -0700 | [diff] [blame] | 35 | allow netd system_prop:property_service set; |
Stephen Smalley | fee4915 | 2014-06-19 10:27:02 -0400 | [diff] [blame] | 36 | auditallow netd system_prop:property_service set; |
Nick Kralevich | dbd28d9 | 2013-06-27 15:11:02 -0700 | [diff] [blame] | 37 | |
| 38 | # Connect to PAN |
Stephen Smalley | 9de4c69 | 2013-04-04 11:31:00 -0400 | [diff] [blame] | 39 | domain_auto_trans(netd, dhcp_exec, dhcp) |
Nick Kralevich | dbd28d9 | 2013-06-27 15:11:02 -0700 | [diff] [blame] | 40 | allow netd dhcp:process signal; |
| 41 | |
| 42 | # Needed to update /data/misc/wifi/hostapd.conf |
| 43 | # TODO: See what we can do to reduce the need for |
| 44 | # these capabilities |
| 45 | allow netd self:capability { dac_override chown fowner }; |
| 46 | allow netd wifi_data_file:file create_file_perms; |
Paul Zhang | 67d9cba | 2014-09-16 10:53:38 +0800 | [diff] [blame] | 47 | allow netd wifi_data_file:dir create_dir_perms; |
| 48 | allow netd wifi_data_file:sock_file { create setattr unlink write }; |
| 49 | |
| 50 | # Allow netd to chmod dir /data/misc/dhcp |
| 51 | allow netd dhcp_data_file:dir create_dir_perms; |
Nick Kralevich | dbd28d9 | 2013-06-27 15:11:02 -0700 | [diff] [blame] | 52 | |
Sreeram Ramachandran | 65edb75 | 2014-07-07 22:04:57 -0700 | [diff] [blame] | 53 | # Needed to update /data/misc/net/rt_tables |
| 54 | allow netd net_data_file:file create_file_perms; |
| 55 | allow netd net_data_file:dir rw_dir_perms; |
| 56 | |
Nick Kralevich | dbd28d9 | 2013-06-27 15:11:02 -0700 | [diff] [blame] | 57 | # Allow netd to spawn hostapd in it's own domain |
| 58 | domain_auto_trans(netd, hostapd_exec, hostapd) |
| 59 | allow netd hostapd:process signal; |
| 60 | |
| 61 | # Allow netd to spawn dnsmasq in it's own domain |
| 62 | domain_auto_trans(netd, dnsmasq_exec, dnsmasq) |
| 63 | allow netd dnsmasq:process signal; |
| 64 | |
Lorenzo Colitti | ab7dfab | 2013-08-05 15:32:56 +0900 | [diff] [blame] | 65 | # Allow netd to start clatd in its own domain |
| 66 | domain_auto_trans(netd, clatd_exec, clatd) |
| 67 | allow netd clatd:process signal; |
| 68 | |
Robert Craig | 4b3893f | 2014-02-18 13:24:26 -0500 | [diff] [blame] | 69 | allow netd ctl_mdnsd_prop:property_service set; |
Nick Kralevich | 9a19885 | 2013-07-12 21:28:41 -0700 | [diff] [blame] | 70 | |
Sreeram Ramachandran | 56ecf4b | 2014-05-01 11:12:10 -0700 | [diff] [blame] | 71 | # Allow netd to operate on sockets that are passed to it. |
| 72 | allow netd netdomain:{tcp_socket udp_socket rawip_socket dccp_socket tun_socket} {read write getattr setattr getopt setopt}; |
| 73 | allow netd netdomain:fd use; |
| 74 | |
Nick Kralevich | 9a19885 | 2013-07-12 21:28:41 -0700 | [diff] [blame] | 75 | ### |
| 76 | ### Neverallow rules |
| 77 | ### |
| 78 | ### netd should NEVER do any of this |
| 79 | |
| 80 | # Block device access. |
| 81 | neverallow netd dev_type:blk_file { read write }; |
| 82 | |
Nick Kralevich | 9a19885 | 2013-07-12 21:28:41 -0700 | [diff] [blame] | 83 | # ptrace any other app |
| 84 | neverallow netd { domain }:process ptrace; |
| 85 | |
| 86 | # Write to /system. |
| 87 | neverallow netd system_file:dir_file_class_set write; |
| 88 | |
| 89 | # Write to files in /data/data or system files on /data |
| 90 | neverallow netd { app_data_file system_data_file }:dir_file_class_set write; |