Skip to content

Commit 6beab6b

Browse files
authored
Merge pull request #1176 from jaihindy/adb_shell_sepolicy
adb: add SELinux policy for adbd and interactive adb shell session
2 parents c3dad3e + a1a878c commit 6beab6b

3 files changed

Lines changed: 164 additions & 0 deletions

File tree

policy/modules/services/adb.fc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/usr/bin/adbd -- gen_context(system_u:object_r:adbd_exec_t,s0)

policy/modules/services/adb.if

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## <summary>Policy for adb</summary>
2+
########################################
3+
## <summary>
4+
## Allow processes to inherit adbd file descriptors.
5+
## </summary>
6+
## <param name="domain">
7+
## <summary>
8+
## Domain allowed access.
9+
## </summary>
10+
## </param>
11+
#
12+
interface(`adb_use_fds',`
13+
gen_require(`
14+
type adbd_t;
15+
')
16+
17+
allow $1 adbd_t:fd use;
18+
')

policy/modules/services/adb.te

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
policy_module(adb)
2+
3+
########################################
4+
#
5+
# Declarations
6+
#
7+
########################################
8+
9+
## <desc>
10+
## <p>
11+
## Allow extended adb shell functionality for debugging and interactive shell access.
12+
## </p>
13+
## </desc>
14+
gen_tunable(adb_shell_extended_access, false)
15+
16+
## <desc>
17+
## <p>
18+
## Allow adb shell sessions to run in unconfined_t instead of the default adb_shell_t
19+
## domain.
20+
## </p>
21+
## </desc>
22+
gen_tunable(adb_unconfined_shell, false)
23+
24+
type adbd_t;
25+
type adbd_exec_t;
26+
init_daemon_domain(adbd_t, adbd_exec_t)
27+
28+
type adb_shell_t;
29+
domain_type(adb_shell_t)
30+
31+
########################################
32+
#
33+
# adbd local policy
34+
#
35+
########################################
36+
37+
allow adbd_t self:capability sys_resource;
38+
39+
corecmd_search_bin(adbd_t)
40+
dev_rw_usbfs(adbd_t)
41+
files_manage_generic_tmp_dirs(adbd_t)
42+
files_manage_generic_tmp_files(adbd_t)
43+
files_read_etc_files(adbd_t)
44+
logging_read_audit_log(adbd_t)
45+
logging_read_generic_logs(adbd_t)
46+
term_use_generic_ptys(adbd_t)
47+
term_use_ptmx(adbd_t)
48+
49+
optional_policy(`
50+
tunable_policy(`adb_unconfined_shell',`
51+
unconfined_shell_domtrans(adbd_t)
52+
',`
53+
corecmd_shell_domtrans(adbd_t, adb_shell_t)
54+
')
55+
')
56+
57+
########################################
58+
#
59+
# adb_shell local policy
60+
#
61+
########################################
62+
role system_r types adb_shell_t;
63+
64+
allow adb_shell_t self:process { getcap setpgid signal };
65+
allow adb_shell_t self:fifo_file rw_inherited_fifo_file_perms;
66+
67+
allow adb_shell_t adbd_t:fd use;
68+
69+
corecmd_exec_bin(adb_shell_t)
70+
corecmd_shell_entry_type(adb_shell_t)
71+
72+
dev_search_sysfs(adb_shell_t)
73+
74+
files_getattr_var_lib_dirs(adb_shell_t)
75+
files_list_default(adb_shell_t)
76+
files_manage_generic_tmp_dirs(adb_shell_t)
77+
files_manage_generic_tmp_files(adb_shell_t)
78+
files_read_default_files(adb_shell_t)
79+
files_read_etc_files(adb_shell_t)
80+
files_read_mnt_files(adb_shell_t)
81+
files_read_mnt_symlinks(adb_shell_t)
82+
files_read_usr_symlinks(adb_shell_t)
83+
files_read_var_symlinks(adb_shell_t)
84+
files_search_spool(adb_shell_t)
85+
files_search_tmp(adb_shell_t)
86+
files_search_var(adb_shell_t)
87+
fs_getattr_xattr_fs(adb_shell_t)
88+
fs_list_auto_mountpoints(adb_shell_t)
89+
90+
kernel_read_kernel_sysctls(adb_shell_t)
91+
92+
logging_list_logs(adb_shell_t)
93+
logging_manage_generic_logs(adb_shell_t)
94+
logging_read_audit_log(adb_shell_t)
95+
logging_read_generic_logs(adb_shell_t)
96+
logging_rw_generic_log_dirs(adb_shell_t)
97+
logging_search_logs(adb_shell_t)
98+
99+
seutil_read_config(adb_shell_t)
100+
101+
term_use_generic_ptys(adb_shell_t)
102+
term_use_ptmx(adb_shell_t)
103+
104+
userdom_search_user_home_dirs(adb_shell_t)
105+
106+
tunable_policy(`adb_shell_extended_access',`
107+
corecmd_getattr_all_executables(adb_shell_t)
108+
dev_read_kmsg(adb_shell_t)
109+
dmesg_exec(adb_shell_t)
110+
111+
files_manage_var_dirs(adb_shell_t)
112+
files_manage_var_files(adb_shell_t)
113+
files_read_etc_runtime_files(adb_shell_t)
114+
files_read_usr_symlinks(adb_shell_t)
115+
init_get_generic_units_status(adb_shell_t)
116+
init_get_runtime_units_status(adb_shell_t)
117+
init_get_system_status(adb_shell_t)
118+
119+
init_read_generic_units_symlinks(adb_shell_t)
120+
init_reload_generic_units(adb_shell_t)
121+
init_stream_connect(adb_shell_t)
122+
init_write_runtime_socket(adb_shell_t)
123+
124+
kernel_read_fs_sysctls(adb_shell_t)
125+
kernel_read_ring_buffer(adb_shell_t)
126+
kernel_read_vm_sysctls(adb_shell_t)
127+
128+
mount_exec(adb_shell_t)
129+
selinux_get_fs_mount(adb_shell_t)
130+
selinux_read_policy(adb_shell_t)
131+
132+
systemd_dbus_chat_logind(adb_shell_t)
133+
systemd_list_journal_dirs(adb_shell_t)
134+
systemd_read_journal_files(adb_shell_t)
135+
sysnet_domtrans_ifconfig(adb_shell_t)
136+
userdom_use_user_terminals(adb_shell_t)
137+
')
138+
139+
optional_policy(`
140+
dbus_system_bus_client(adb_shell_t)
141+
')
142+
143+
optional_policy(`
144+
dnsmasq_domtrans(adb_shell_t)
145+
')

0 commit comments

Comments
 (0)