Skip to content

Commit 474e108

Browse files
etbeperfinion
authored andcommitted
strict (#999)
* Some patches needed to run in a strict configuration Signed-off-by: Russell Coker <russell@coker.com.au> Signed-off-by: Jason Zaman <perfinion@gentoo.org>
1 parent 59fbd79 commit 474e108

4 files changed

Lines changed: 77 additions & 4 deletions

File tree

policy/modules/apps/pulseaudio.te

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ files_type(pulseaudio_var_lib_t)
5151
type pulseaudio_xdg_config_t;
5252
xdg_config_content(pulseaudio_xdg_config_t)
5353

54+
type pulseaudio_xdg_cache_t;
55+
xdg_cache_content(pulseaudio_xdg_cache_t)
56+
5457
########################################
5558
#
5659
# Local policy
@@ -76,6 +79,7 @@ userdom_user_home_dir_filetrans(pulseaudio_t, pulseaudio_home_t, file, ".pulse-c
7679

7780
manage_dirs_pattern(pulseaudio_t, pulseaudio_tmp_t, pulseaudio_tmp_t)
7881
manage_files_pattern(pulseaudio_t, pulseaudio_tmp_t, pulseaudio_tmp_t)
82+
allow pulseaudio_t pulseaudio_tmp_t:file map;
7983
manage_sock_files_pattern(pulseaudio_t, pulseaudio_tmp_t, pulseaudio_tmp_t)
8084
files_tmp_filetrans(pulseaudio_t, pulseaudio_tmp_t, { dir sock_file })
8185
userdom_user_runtime_filetrans(pulseaudio_t, pulseaudio_tmp_t, dir)
@@ -103,6 +107,11 @@ manage_dirs_pattern(pulseaudio_t, pulseaudio_xdg_config_t, pulseaudio_xdg_config
103107
manage_files_pattern(pulseaudio_t, pulseaudio_xdg_config_t, pulseaudio_xdg_config_t)
104108
allow pulseaudio_t pulseaudio_xdg_config_t:file map;
105109

110+
manage_dirs_pattern(pulseaudio_t, pulseaudio_xdg_cache_t, pulseaudio_xdg_cache_t)
111+
manage_files_pattern(pulseaudio_t, pulseaudio_xdg_cache_t, pulseaudio_xdg_cache_t)
112+
allow pulseaudio_t pulseaudio_xdg_cache_t:file map;
113+
xdg_cache_filetrans(pulseaudio_t, pulseaudio_xdg_cache_t, dir)
114+
106115
xdg_config_filetrans(pulseaudio_t, pulseaudio_xdg_config_t, dir, "pulse")
107116

108117
allow pulseaudio_t pulseaudio_client:process signull;
@@ -122,8 +131,12 @@ dev_read_sound(pulseaudio_t)
122131
dev_write_sound(pulseaudio_t)
123132
dev_read_sysfs(pulseaudio_t)
124133
dev_read_urand(pulseaudio_t)
134+
dev_rw_dri(pulseaudio_t)
135+
dev_read_video_dev(pulseaudio_t)
136+
dev_write_video_dev(pulseaudio_t)
125137

126138
files_read_usr_files(pulseaudio_t)
139+
files_map_usr_files(pulseaudio_t)
127140

128141
fs_getattr_tmpfs(pulseaudio_t)
129142
fs_getattr_all_fs(pulseaudio_t)
@@ -136,6 +149,9 @@ term_use_all_ptys(pulseaudio_t)
136149

137150
auth_use_nsswitch(pulseaudio_t)
138151

152+
# for /usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner
153+
libs_exec_lib_files(pulseaudio_t)
154+
139155
logging_send_syslog_msg(pulseaudio_t)
140156

141157
miscfiles_read_localization(pulseaudio_t)
@@ -202,6 +218,7 @@ optional_policy(`
202218
dbus_system_domain(pulseaudio_t, pulseaudio_exec_t)
203219
dbus_all_session_bus_client(pulseaudio_t)
204220
dbus_connect_all_session_bus(pulseaudio_t)
221+
dbus_getattr_session_runtime_socket(pulseaudio_t)
205222

206223
optional_policy(`
207224
policykit_dbus_chat(pulseaudio_t)

policy/modules/apps/wm.if

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,19 @@ template(`wm_role_template',`
5353
# Policy
5454
#
5555

56+
allow $1_wm_t self:process getcap;
57+
5658
allow $3 $1_wm_t:fd use;
5759

58-
allow $1_wm_t $3:unix_stream_socket connectto;
59-
allow $3 $1_wm_t:unix_stream_socket connectto;
60+
allow $1_wm_t $3:unix_stream_socket { connectto read write getopt getattr accept };
61+
allow $3 $1_wm_t:unix_stream_socket { connectto read write getopt };
6062

61-
allow $3 $1_wm_t:process { ptrace signal_perms };
63+
# ptrace here would allow messing with keyboard
64+
allow $3 $1_wm_t:process { signal_perms };
6265
ps_process_pattern($3, $1_wm_t)
6366

64-
allow $1_wm_t $3:process { sigkill signull };
67+
allow $1_wm_t $3:process { sigkill signull signal };
68+
ps_process_pattern($1_wm_t, $3)
6569

6670
domtrans_pattern($3, wm_exec_t, $1_wm_t)
6771

@@ -74,10 +78,14 @@ template(`wm_role_template',`
7478
mls_xwin_write_all_levels($1_wm_t)
7579
mls_fd_use_all_levels($1_wm_t)
7680

81+
auth_domtrans_chk_passwd($1_wm_t)
7782
auth_use_nsswitch($1_wm_t)
7883

7984
miscfiles_manage_fonts_cache($1_wm_t)
8085

86+
userdom_rw_user_tmpfs_files($1_wm_t)
87+
userdom_map_user_tmpfs_files($1_wm_t)
88+
8189
xserver_role($1, $1_wm_t, $3, $4)
8290
xserver_manage_core_devices($1_wm_t)
8391

@@ -97,6 +105,10 @@ template(`wm_role_template',`
97105
gnome_stream_connect_all_gkeyringd($1_wm_t)
98106
')
99107

108+
optional_policy(`
109+
modemmanager_dbus_chat($1_wm_t)
110+
')
111+
100112
optional_policy(`
101113
networkmanager_watch_etc_dirs($1_wm_t)
102114
')
@@ -111,7 +123,9 @@ template(`wm_role_template',`
111123
')
112124

113125
optional_policy(`
126+
systemd_read_logind_state($1_wm_t)
114127
systemd_user_app_status($1, $1_wm_t)
128+
systemd_write_inherited_logind_inhibit_pipes($1_wm_t)
115129
')
116130

117131
optional_policy(`

policy/modules/services/dbus.if

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ template(`dbus_role_template',`
8888

8989
allow $3 $1_dbusd_t:unix_stream_socket { connectto create_stream_socket_perms };
9090
allow $3 $1_dbusd_t:dbus { acquire_svc send_msg };
91+
allow $1_dbusd_t $3:dbus send_msg;
9192
allow $3 $1_dbusd_t:fd use;
9293

9394
dontaudit $1_dbusd_t self:process getcap;
@@ -101,7 +102,14 @@ template(`dbus_role_template',`
101102
allow $3 session_dbusd_runtime_t:sock_file { manage_sock_file_perms relabel_sock_file_perms };
102103
userdom_user_home_dir_filetrans($3, session_dbusd_home_t, dir, ".dbus")
103104

105+
userdom_delete_user_tmp_named_sockets($1_dbusd_t)
106+
userdom_manage_user_tmp_dirs($1_dbusd_t)
107+
108+
# for app-at\x2dspi\x2ddbus\x2dbus@autostart.service
109+
userdom_manage_user_tmp_sockets($1_dbusd_t)
110+
104111
domtrans_pattern($3, dbusd_exec_t, $1_dbusd_t)
112+
can_exec($1_dbusd_t, dbusd_exec_t)
105113

106114
ps_process_pattern($3, $1_dbusd_t)
107115
allow $3 $1_dbusd_t:process { ptrace signal_perms };
@@ -132,6 +140,7 @@ template(`dbus_role_template',`
132140
')
133141

134142
dbus_exec($1_dbusd_t)
143+
files_read_etc_runtime_files($1_dbusd_t)
135144

136145
optional_policy(`
137146
systemd_read_logind_runtime_files($1_dbusd_t)
@@ -140,6 +149,15 @@ template(`dbus_role_template',`
140149
systemd_user_unix_stream_activated_socket($1_dbusd_t, session_dbusd_runtime_t)
141150
')
142151

152+
optional_policy(`
153+
init_dbus_chat($1_dbusd_t)
154+
dbus_system_bus_client($1_dbusd_t)
155+
')
156+
157+
optional_policy(`
158+
xdg_read_data_files($1_dbusd_t)
159+
')
160+
143161
optional_policy(`
144162
xserver_read_xdm_lib_files($1_dbusd_t)
145163
')

policy/modules/system/systemd.if

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ template(`systemd_role_template',`
2424
gen_require(`
2525
class service { reload start status stop };
2626
class system { disable enable reload start status stop };
27+
class dbus send_msg;
2728
attribute systemd_user_session_type, systemd_log_parse_env_type;
2829
attribute systemd_user_activated_sock_file_type, systemd_user_unix_stream_activated_socket_type;
2930
type systemd_analyze_exec_t, systemd_cgtop_exec_t;
@@ -68,6 +69,9 @@ template(`systemd_role_template',`
6869
corecmd_shell_domtrans($1_systemd_t, $3)
6970
corecmd_bin_domtrans($1_systemd_t, $3)
7071

72+
allow $3 $1_systemd_t:dbus send_msg;
73+
allow $1_systemd_t $3:dbus send_msg;
74+
7175
# systemctl --user rules
7276
allow $1_systemd_t systemd_user_unix_stream_activated_socket_type:unix_stream_socket { create_socket_perms listen };
7377
allow $1_systemd_t systemd_user_activated_sock_file_type:dir manage_dir_perms;
@@ -93,7 +97,10 @@ template(`systemd_role_template',`
9397
allow $1_systemd_t $3:file read_file_perms;
9498
allow $1_systemd_t $3:lnk_file read_lnk_file_perms;
9599

100+
dev_getattr_sound_dev($1_systemd_t)
96101
dev_read_urand($1_systemd_t)
102+
storage_getattr_removable_dev($1_systemd_t)
103+
term_dontaudit_getattr_unallocated_ttys($1_systemd_t)
97104

98105
files_search_home($1_systemd_t)
99106
files_watch_etc_dirs($1_systemd_t)
@@ -104,6 +111,8 @@ template(`systemd_role_template',`
104111
fs_watch_cgroup_files($1_systemd_t)
105112

106113
kernel_dontaudit_getattr_proc($1_systemd_t)
114+
kernel_read_psi($1_systemd_t)
115+
107116
# if systemd exists in the initrd, the journal socket stays labeled kernel_t
108117
# without this access, user services cannot log to the journal
109118
kernel_stream_connect($1_systemd_t)
@@ -229,9 +238,23 @@ template(`systemd_role_template',`
229238

230239
systemd_watch_passwd_runtime_dirs($3)
231240

241+
optional_policy(`
242+
gpg_stream_connect_agent($1_systemd_t)
243+
')
244+
245+
optional_policy(`
246+
modemmanager_dbus_chat($1_systemd_t)
247+
')
248+
249+
optional_policy(`
250+
pulseaudio_domtrans($1_systemd_t)
251+
pulseaudio_manage_tmp_dirs($1_systemd_t)
252+
')
253+
232254
optional_policy(`
233255
xdg_config_filetrans($1_systemd_t, systemd_conf_home_t, dir, "systemd")
234256
xdg_data_filetrans($1_systemd_t, systemd_data_home_t, dir, "systemd")
257+
xdg_read_cache_files($1_systemd_t)
235258
xdg_read_config_files($1_systemd_t)
236259
xdg_read_data_files($1_systemd_t)
237260
')
@@ -271,6 +294,7 @@ template(`systemd_user_daemon_domain',`
271294
')
272295

273296
domtrans_pattern($1_systemd_t, $2, $3)
297+
allow $1_systemd_t $3:process noatsecure;
274298

275299
systemd_user_app_status($1, $3)
276300
')

0 commit comments

Comments
 (0)