Skip to contentSkip to conversation

alsactl policy

PATCH Martin Orr 2 participants 2 messages Jul 24, 2007 – Jul 27, 2007 SELinux security module

lore
Share & tools
lore

Martin Orr

author
#0 lore raw

The alsa policy doesn't address alsactl, run from an init script and via a udev rule whenever a sound device is loaded to set volumes. This patch addresses this. Since I have never written SELinux policy before, all comments are appreciated.

Signature · 1 line
Martin Orr
modules/system/init.te +4 -0
Index: policy/modules/system/init.te
===================================================================
@@ -541,6 +541,10 @@
 ')
 
 optional_policy(`
+	alsa_domtrans(initrc_t)
+')
+
+optional_policy(`
 	amavis_search_lib(initrc_t)
 	amavis_setattr_pid_files(initrc_t)
 ')
modules/system/udev.te +4 -0
Index: policy/modules/system/udev.te
===================================================================
@@ -176,6 +176,10 @@
 ')
 
 optional_policy(`
+	alsa_domtrans(udev_t)
+')
+
+optional_policy(`
 	consoletype_exec(udev_t)
 ')
 
modules/admin/alsa.te +15 -0
Index: policy/modules/admin/alsa.te
===================================================================
@@ -14,6 +14,9 @@
 type alsa_etc_rw_t;
 files_type(alsa_etc_rw_t)
 
+type alsa_var_lib_t;
+files_type(alsa_var_lib_t)
+
 ########################################
 #
 # Local policy
@@ -30,9 +33,20 @@
 manage_lnk_files_pattern(alsa_t,alsa_etc_rw_t,alsa_etc_rw_t)
 
 files_read_etc_files(alsa_t)
+files_read_usr_files(alsa_t)
+files_search_pids(alsa_t)
 
+# asound.state: lives in /var/lib/alsa on Debian, /etc elsewhere
+files_etc_filetrans(alsa_t,alsa_etc_rw_t,file)
+files_search_var_lib(alsa_t)
+manage_files_pattern(alsa_t,alsa_var_lib_t,alsa_var_lib_t)
+
+dev_read_sound(alsa_t)
+dev_write_sound(alsa_t)
+
 term_use_generic_ptys(alsa_t)
 term_dontaudit_use_unallocated_ttys(alsa_t)
+init_dontaudit_use_fds(alsa_t)
 
 libs_use_ld_so(alsa_t)
 libs_use_shared_libs(alsa_t)
@@ -43,6 +57,7 @@
 
 userdom_manage_unpriv_user_semaphores(alsa_t)
 userdom_manage_unpriv_user_shared_mem(alsa_t)
+userdom_search_generic_user_home_dirs(alsa_t)
 
 optional_policy(`
 	nscd_socket_use(alsa_t)
modules/admin/alsa.fc +4 -0
Index: policy/modules/admin/alsa.fc
===================================================================
@@ -1,4 +1,8 @@
 
 /etc/alsa/pcm(/.*)?		gen_context(system_u:object_r:alsa_etc_rw_t,s0)
 
+/etc/asound\.state	--	gen_context(system_u:object_r:alsa_etc_rw_t,s0)
+/var/lib/alsa(/.*)?		gen_context(system_u:object_r:alsa_var_lib_t,s0)
+
 /usr/bin/ainit 		--	gen_context(system_u:object_r:alsa_exec_t,s0)
+/usr/sbin/alsactl	--	gen_context(system_u:object_r:alsa_exec_t,s0)
#1 lore raw
Quoted 7 lines · Martin Orr

The alsa policy doesn't address alsactl, run from an init script and via a
udev rule whenever a sound device is loaded to set volumes. This patch
addresses this.

modules/system/init.te line 550

Quoted 10 lines
modules/system/init.te +4 -0
@@ -541,6 +541,10 @@
 ')
 
 optional_policy(`
+	alsa_domtrans(initrc_t)
+')
+
+optional_policy(`
 	amavis_search_lib(initrc_t)
 	amavis_setattr_pid_files(initrc_t)
 ')

This should be init_system_domain() in alsa.te instead.

modules/system/udev.te line 184

Quoted 10 lines
modules/system/udev.te +4 -0
@@ -176,6 +176,10 @@
 ')
 
 optional_policy(`
+	alsa_domtrans(udev_t)
+')
+
+optional_policy(`
 	consoletype_exec(udev_t)
 ')

What causes udev to run this (might it be debian-specific)?

Quoted 7 lines
modules/admin/alsa.te +3 -0
@@ -14,6 +14,9 @@
 type alsa_etc_rw_t;
 files_type(alsa_etc_rw_t)
 
+type alsa_var_lib_t;
+files_type(alsa_var_lib_t)
+

[...]

modules/admin/alsa.te line 42

Quoted 4 lines
modules/admin/alsa.te +4 -0
+# asound.state: lives in /var/lib/alsa on Debian, /etc elsewhere
+files_etc_filetrans(alsa_t,alsa_etc_rw_t,file)
+files_search_var_lib(alsa_t)
+manage_files_pattern(alsa_t,alsa_var_lib_t,alsa_var_lib_t)

This is the problem with encoding paths into the type names. It might be in different paths, but its the same file, with the same security attributes, so there isn't a need for a new type. Since the /var/lib stuff is debian-specific, it should be in a ifdef(`distro_debian'.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.