Biswajit Paul | 28439f9 | 2015-07-15 13:28:27 -0700 | [diff] [blame] | 1 | # Copyright (c) 2015, The Linux Foundation. All rights reserved. |
| 2 | # |
| 3 | # Redistribution and use in source and binary forms, with or without |
| 4 | # modification, are permitted provided that the following conditions are |
| 5 | # met: |
| 6 | # * Redistributions of source code must retain the above copyright |
| 7 | # notice, this list of conditions and the following disclaimer. |
| 8 | # * Redistributions in binary form must reproduce the above |
| 9 | # copyright notice, this list of conditions and the following |
| 10 | # disclaimer in the documentation and/or other materials provided |
| 11 | # with the distribution. |
| 12 | # * Neither the name of The Linux Foundation nor the names of its |
| 13 | # contributors may be used to endorse or promote products derived |
| 14 | # from this software without specific prior written permission. |
| 15 | # |
| 16 | # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | # RIDL |
Biswajit Paul | 6786a92 | 2017-03-16 11:53:53 -0700 | [diff] [blame] | 29 | type RIDL, domain; |
Ravi Kumar Siddojigari | c7def12 | 2017-06-13 00:49:19 +0530 | [diff] [blame] | 30 | type RIDL_exec, exec_type, vendor_file_type, file_type; |
Biswajit Paul | 28439f9 | 2015-07-15 13:28:27 -0700 | [diff] [blame] | 31 | |
Biswajit Paul | 28439f9 | 2015-07-15 13:28:27 -0700 | [diff] [blame] | 32 | allow RIDL RIDL_socket:sock_file create_file_perms; |
| 33 | allow RIDL RIDL_socket:dir create_dir_perms; |
| 34 | |
| 35 | # make transition from init to its domain |
| 36 | init_daemon_domain(RIDL) |
| 37 | |
| 38 | # allow socket connections to us |
| 39 | net_domain(RIDL) |
| 40 | |
| 41 | allow RIDL RIDL_data_file:dir create_dir_perms; |
| 42 | allow RIDL RIDL_data_file:file create_file_perms; |
| 43 | allow RIDL RIDL_data_file:lnk_file { create read unlink }; |
Biswajit Paul | 9d2dd04 | 2017-02-01 12:38:16 -0800 | [diff] [blame] | 44 | userdebug_or_eng(` |
Ravi Kumar Siddojigari | 92eed18 | 2017-06-27 00:25:03 +0530 | [diff] [blame] | 45 | allow RIDL qti_debugfs:file read; |
Biswajit Paul | 9d2dd04 | 2017-02-01 12:38:16 -0800 | [diff] [blame] | 46 | ') |
Biswajit Paul | 28439f9 | 2015-07-15 13:28:27 -0700 | [diff] [blame] | 47 | |
| 48 | # ver_info.txt |
| 49 | r_dir_file(RIDL, firmware_file) |
| 50 | |
| 51 | # sdcard0/1 |
| 52 | allow RIDL fuse:dir create_dir_perms; |
| 53 | allow RIDL fuse:file create_file_perms; |
| 54 | |
| 55 | # dmesg |
| 56 | allow RIDL kernel:system syslog_read; |
| 57 | |
| 58 | # QMUX |
| 59 | qmux_socket(RIDL) |
| 60 | |
| 61 | # ramdumps |
| 62 | allow RIDL ramdump_device:chr_file rw_file_perms; |
| 63 | |
| 64 | # logcat |
| 65 | unix_socket_connect(RIDL, logdr, logd) |
| 66 | |
Ravi Kumar Siddojigari | c7def12 | 2017-06-13 00:49:19 +0530 | [diff] [blame] | 67 | #binder_use(RIDL) |
| 68 | allow RIDL vendor_shell_exec:file { rx_file_perms }; |
Biswajit Paul | 28439f9 | 2015-07-15 13:28:27 -0700 | [diff] [blame] | 69 | allow RIDL sysfs:file write; |
| 70 | allow RIDL system_file:file x_file_perms; |
| 71 | binder_call(RIDL, system_server) |
Shruthi Krishna | a24dd28 | 2015-09-16 14:17:07 -0700 | [diff] [blame] | 72 | |
| 73 | # recovery |
| 74 | allow RIDL cache_file:dir create_dir_perms; |
| 75 | allow RIDL cache_file:file create_file_perms; |
Clarence Wong | d79aea3 | 2016-10-07 14:41:04 -0700 | [diff] [blame] | 76 | allow RIDL cache_recovery_file:dir rw_dir_perms; |
| 77 | allow RIDL cache_recovery_file:file create_file_perms; |
Shruthi Krishna | a24dd28 | 2015-09-16 14:17:07 -0700 | [diff] [blame] | 78 | |
| 79 | # reboot recovery |
sahil madeka | a3608c9 | 2017-05-12 15:41:40 -0700 | [diff] [blame] | 80 | set_prop(RIDL, powerctl_prop) |
Shruthi Krishna | a24dd28 | 2015-09-16 14:17:07 -0700 | [diff] [blame] | 81 | |
Divya Sharma | 8fa27ad | 2015-11-03 15:10:41 -0800 | [diff] [blame] | 82 | # ANR |
| 83 | allow RIDL anr_data_file:dir r_dir_perms; |
| 84 | allow RIDL anr_data_file:file r_file_perms; |
| 85 | |
| 86 | # detect /data/anr directory is created |
| 87 | allow RIDL system_data_file:dir read; |
| 88 | |
Shruthi Krishna | a24dd28 | 2015-09-16 14:17:07 -0700 | [diff] [blame] | 89 | userdebug_or_eng(` |
Panwar Vivek | a7b60ec | 2015-09-10 13:50:31 +0530 | [diff] [blame] | 90 | # Access to ANR/segfaults |
Shruthi Krishna | a24dd28 | 2015-09-16 14:17:07 -0700 | [diff] [blame] | 91 | allow RIDL tombstone_data_file:dir rw_dir_perms; |
| 92 | allow RIDL tombstone_data_file:file { unlink rw_file_perms }; |
Manish Kumar | 8519d71 | 2015-11-04 11:12:08 +0530 | [diff] [blame] | 93 | allow RIDL anr_data_file:dir rw_dir_perms; |
| 94 | allow RIDL anr_data_file:file { unlink rw_file_perms }; |
Panwar Vivek | a7b60ec | 2015-09-10 13:50:31 +0530 | [diff] [blame] | 95 | |
| 96 | # tcpdump |
Biswajit Paul | 2d35d98 | 2017-02-01 17:40:10 -0800 | [diff] [blame] | 97 | allow RIDL self:packet_socket create_socket_perms_no_ioctl; |
Panwar Vivek | a7b60ec | 2015-09-10 13:50:31 +0530 | [diff] [blame] | 98 | allow RIDL self:capability net_raw; |
Clarence Wong | 9fdb145 | 2016-10-04 11:28:34 -0700 | [diff] [blame] | 99 | diag_use( RIDL ) |
Clarence Wong | b5b68d9 | 2015-11-24 13:03:37 -0800 | [diff] [blame] | 100 | |
| 101 | # allow location |
Ravi Kumar Siddojigari | c7def12 | 2017-06-13 00:49:19 +0530 | [diff] [blame] | 102 | #allow RIDL app_api_service:service_manager find; |
Shruthi Krishna | a24dd28 | 2015-09-16 14:17:07 -0700 | [diff] [blame] | 103 | ') |
Panwar Vivek | a7b60ec | 2015-09-10 13:50:31 +0530 | [diff] [blame] | 104 | |
| 105 | # drop root caps |
| 106 | allow RIDL self:capability { setuid setgid }; |
| 107 | |
| 108 | # access to /proc/kmsg |
| 109 | allow RIDL self:capability2 syslog; |
| 110 | allow RIDL kernel:system syslog_mod; |
Manish Kumar | 6cbbdc7 | 2015-11-04 11:12:58 +0530 | [diff] [blame] | 111 | |
| 112 | # allow access to /storage/ for sdcard |
| 113 | allow RIDL storage_file:dir r_dir_perms; |
| 114 | |
| 115 | # allow logcat access |
Ravi Kumar Siddojigari | c7def12 | 2017-06-13 00:49:19 +0530 | [diff] [blame] | 116 | #read_logd( RIDL ); |
Clarence Wong | b5b68d9 | 2015-11-24 13:03:37 -0800 | [diff] [blame] | 117 | |
| 118 | # allow netstats |
Ravi Kumar Siddojigari | c7def12 | 2017-06-13 00:49:19 +0530 | [diff] [blame] | 119 | #allow RIDL system_api_service:service_manager find; |
Clarence Wong | 94ec564 | 2016-07-28 14:09:58 -0700 | [diff] [blame] | 120 | |
| 121 | # allow toybox execution for getprop on OS 24 and later |
Ravi Kumar Siddojigari | c7def12 | 2017-06-13 00:49:19 +0530 | [diff] [blame] | 122 | allow RIDL vendor_toolbox_exec:file rx_file_perms; |