Changes to the pulseaudio policy module and its dependencies
I am currently trying to port the pulseaudio policy module with changes
I would like your opinion on patch below
Some explanation:
applications that run pulseadio for their audio have things in common:
they use shared memory
The need to be able to read and delete eachothers shared memory they need to be able to signal signull eachother
They need to be able to restart pulseaudio if it crashes
They need to be able to connect to pulseaudio over the network if there is no local pulse running (conditional?)
They need various access to pulse audio home content They need to be able to stream connect to pulseaudio
The need to be able to dbus chat to pulseaudio
Since pulseaudio as a system service uses the same domain they need to be a system bus client
If you think about it , this can get quite messy if we dont do it tidy
I decided to create two type attributes
the pulseaudio_client is a attribute that is assigned to anyone domain transitioning to pulseaudio_t
This is a prerequisite for pulse clients be cause they need to be able to restart pulse if it crashes
The pulseaudio client attribute is used to write policy efficient that is common to pulseaudio clients
P.S. pulseaudio_role() callers are also pulse_client, they just have a little extra permissions
The pulseaudio_tmpfs_file_type is assigned to all clients tmpfile file types separately with the pulseaudio_tmpfs_content() interface
pulseaudio_clients atomatically get the access they need to pulseaudio tmpfs content
read and delete the content
userdom user tmpfs content is not pulseaudio tmpfs content. Thus all pulseaudio_client also need access to read and delete user tmpfs files. ( programs using pulseaudio might run in the user domain
I am probably overlooking things in this version of the patch
Please let me know what you think about this and give me suggestions
gpg.te +3 -21
@@ -1,4 +1,4 @@ -policy_module(gpg, 2.7.2) +policy_module(gpg, 2.7.3) ######################################## #
@@ -67,6 +67,7 @@ type gpg_pinentry_tmpfs_t; userdom_user_tmpfs_file(gpg_pinentry_tmpfs_t) +pulseaudio_tmpfs_content(gpg_pinentry_tmpfs_t) ######################################## #
@@ -275,14 +276,9 @@ allow gpg_pinentry_t self:fifo_file rw_fifo_file_perms; allow gpg_pinentry_t self:shm create_shm_perms; allow gpg_pinentry_t self:tcp_socket { accept listen }; -allow gpg_pinentry_t self:unix_dgram_socket sendto; manage_sock_files_pattern(gpg_pinentry_t, gpg_pinentry_tmp_t, gpg_pinentry_tmp_t) userdom_user_tmp_filetrans(gpg_pinentry_t, gpg_pinentry_tmp_t, sock_file) - -manage_dirs_pattern(gpg_pinentry_t, gpg_pinentry_tmpfs_t, gpg_pinentry_tmpfs_t) -manage_files_pattern(gpg_pinentry_t, gpg_pinentry_tmpfs_t, gpg_pinentry_tmpfs_t) -fs_tmpfs_filetrans(gpg_pinentry_t, gpg_pinentry_tmpfs_t, { file dir }) can_exec(gpg_pinentry_t, pinentry_exec_t)
@@ -308,7 +304,6 @@ files_read_usr_files(gpg_pinentry_t) fs_dontaudit_list_inotifyfs(gpg_pinentry_t) -fs_getattr_tmpfs(gpg_pinentry_t) auth_use_nsswitch(gpg_pinentry_t)
@@ -317,16 +312,7 @@ miscfiles_read_fonts(gpg_pinentry_t) miscfiles_read_localization(gpg_pinentry_t) -userdom_read_user_home_content_files(gpg_pinentry_t) userdom_use_user_terminals(gpg_pinentry_t) - -tunable_policy(`use_nfs_home_dirs',` - fs_read_nfs_files(gpg_pinentry_t) -') - -tunable_policy(`use_samba_home_dirs',` - fs_read_cifs_files(gpg_pinentry_t) -') optional_policy(` dbus_all_session_bus_client(gpg_pinentry_t)
@@ -334,11 +320,7 @@ ') optional_policy(` - pulseaudio_exec(gpg_pinentry_t) - pulseaudio_rw_home_files(gpg_pinentry_t) - pulseaudio_setattr_home_dir(gpg_pinentry_t) - pulseaudio_stream_connect(gpg_pinentry_t) - pulseaudio_signull(gpg_pinentry_t) + pulseaudio_run(gpg_pinentry_t, gpg_pinentry_roles) ') optional_policy(`
mozilla.te +6 -7
@@ -1,4 +1,4 @@ -policy_module(mozilla, 2.7.0) +policy_module(mozilla, 2.7.1) ######################################## #
@@ -42,6 +42,7 @@ type mozilla_plugin_tmpfs_t; userdom_user_tmpfs_file(mozilla_plugin_tmpfs_t) +pulseaudio_tmpfs_content(mozilla_plugin_tmpfs_t) type mozilla_plugin_rw_t; files_type(mozilla_plugin_rw_t)
@@ -58,6 +59,7 @@ typealias mozilla_tmpfs_t alias { user_mozilla_tmpfs_t staff_mozilla_tmpfs_t sysadm_mozilla_tmpfs_t }; typealias mozilla_tmpfs_t alias { auditadm_mozilla_tmpfs_t secadm_mozilla_tmpfs_t }; userdom_user_tmpfs_file(mozilla_tmpfs_t) +pulseaudio_tmpfs_content(mozilla_tmpfs_t) ######################################## #
@@ -273,7 +275,7 @@ ') optional_policy(` - lpd_run_lpr(mozilla_plugin_t, mozilla_roles) + lpd_run_lpr(mozilla_t, mozilla_roles) ') optional_policy(`
@@ -283,7 +285,7 @@ ') optional_policy(` - pulseaudio_role(mozilla_roles, mozilla_t) + pulseaudio_run(mozilla_t, mozilla_roles) ') optional_policy(`
@@ -302,10 +304,8 @@ allow mozilla_plugin_t self:sem create_sem_perms; allow mozilla_plugin_t self:shm create_shm_perms; allow mozilla_plugin_t self:tcp_socket { accept listen }; -allow mozilla_plugin_t self:unix_dgram_socket sendto; allow mozilla_plugin_t self:unix_stream_socket { accept connectto listen }; -allow mozilla_plugin_t mozilla_t:process signull; allow mozilla_plugin_t mozilla_t:unix_stream_socket rw_socket_perms; allow mozilla_plugin_t mozilla_t:unix_dgram_socket rw_socket_perms; allow mozilla_plugin_t mozilla_t:shm { rw_shm_perms destroy };
@@ -453,7 +453,6 @@ term_getattr_all_ptys(mozilla_plugin_t) application_exec(mozilla_plugin_t) -application_dontaudit_signull(mozilla_plugin_t) auth_use_nsswitch(mozilla_plugin_t)
@@ -553,7 +552,7 @@ ') optional_policy(` - pulseaudio_role(mozilla_plugin_roles, mozilla_plugin_t) + pulseaudio_run(mozilla_plugin_t, mozilla_plugin_roles) ') optional_policy(`
mpd.te +5 -14
@@ -1,4 +1,4 @@ -policy_module(mpd, 1.0.2) +policy_module(mpd, 1.0.3) ######################################## #
@@ -51,6 +51,7 @@ type mpd_tmpfs_t; files_tmpfs_file(mpd_tmpfs_t) +pulseaudio_tmpfs_content(mpd_tmpfs_t) type mpd_var_lib_t; files_type(mpd_var_lib_t)
@@ -67,7 +68,6 @@ allow mpd_t self:process { getsched setsched setrlimit signal signull }; allow mpd_t self:fifo_file rw_fifo_file_perms; allow mpd_t self:unix_stream_socket { accept connectto listen }; -allow mpd_t self:unix_dgram_socket sendto; allow mpd_t self:tcp_socket { accept listen }; allow mpd_t self:netlink_kobject_uevent_socket create_socket_perms;
@@ -89,7 +89,7 @@ files_tmp_filetrans(mpd_t, mpd_tmp_t, { dir file sock_file }) allow mpd_t mpd_tmpfs_t:file manage_file_perms; -fs_tmpfs_filetrans(mpd_t, mpd_tmpfs_t, file ) +fs_tmpfs_filetrans(mpd_t, mpd_tmpfs_t, file) allow mpd_t mpd_user_data_t:dir list_dir_perms; allow mpd_t mpd_user_data_t:file read_file_perms;
@@ -129,10 +129,6 @@ corenet_sendrecv_http_cache_client_packets(mpd_t) corenet_tcp_connect_http_cache_port(mpd_t) corenet_tcp_sendrecv_http_cache_port(mpd_t) - -corenet_sendrecv_pulseaudio_client_packets(mpd_t) -corenet_tcp_connect_pulseaudio_port(mpd_t) -corenet_tcp_sendrecv_pulseaudio_port(mpd_t) dev_read_sound(mpd_t) dev_write_sound(mpd_t)
@@ -194,17 +190,12 @@ ') optional_policy(` - pulseaudio_exec(mpd_t) - pulseaudio_stream_connect(mpd_t) - pulseaudio_signull(mpd_t) + pulseaudio_domtrans(mpd_t) + ') optional_policy(` rpc_search_nfs_state_data(mpd_t) -') - -optional_policy(` - rtkit_daemon_dbus_chat(mpd_t) ') optional_policy(`
mplayer.te +2 -8
@@ -42,6 +42,7 @@ typealias mplayer_tmpfs_t alias { user_mplayer_tmpfs_t staff_mplayer_tmpfs_t sysadm_mplayer_tmpfs_t }; typealias mplayer_tmpfs_t alias { auditadm_mplayer_tmpfs_t secadm_mplayer_tmpfs_t }; userdom_user_tmpfs_file(mplayer_tmpfs_t) +pulseaudio_tmpfs_content(mplayer_tmpfs_t) ######################################## #
@@ -126,7 +127,6 @@ allow mplayer_t self:process { signal_perms getsched }; allow mplayer_t self:fifo_file rw_fifo_file_perms; allow mplayer_t self:sem create_sem_perms; -allow mplayer_t self:unix_dgram_socket sendto; allow mplayer_t mplayer_etc_t:dir list_dir_perms; allow mplayer_t mplayer_etc_t:file read_file_perms;
@@ -153,10 +153,6 @@ corenet_all_recvfrom_unlabeled(mplayer_t) corenet_tcp_sendrecv_generic_if(mplayer_t) corenet_tcp_sendrecv_generic_node(mplayer_t) - -corenet_sendrecv_pulseaudio_client_packets(mplayer_t) -corenet_tcp_connect_pulseaudio_port(mplayer_t) -corenet_tcp_sendrecv_pulseaudio_port(mplayer_t) corecmd_exec_bin(mplayer_t) corecmd_exec_shell(mplayer_t)
@@ -250,7 +246,5 @@ ') optional_policy(` - pulseaudio_exec(mplayer_t) - pulseaudio_stream_connect(mplayer_t) - pulseaudio_signull(mplayer_t) + pulseaudio_run(mplayer_t, mplayer_roles) ')
pulseaudio.fc +3 -1
@@ -1,7 +1,9 @@ -HOME_DIR/\.pulse-cookie gen_context(system_u:object_r:pulseaudio_home_t,s0) +HOME_DIR/\.esd_auth -- gen_context(system_u:object_r:pulseaudio_home_t,s0) +HOME_DIR/\.pulse-cookie -- gen_context(system_u:object_r:pulseaudio_home_t,s0) HOME_DIR/\.pulse(/.*)? gen_context(system_u:object_r:pulseaudio_home_t,s0) /usr/bin/pulseaudio -- gen_context(system_u:object_r:pulseaudio_exec_t,s0) /var/lib/pulse(/.*)? gen_context(system_u:object_r:pulseaudio_var_lib_t,s0) + /var/run/pulse(/.*)? gen_context(system_u:object_r:pulseaudio_var_run_t,s0)
pulseaudio.if +104 -41
279 lines not on this page · raw message
pulseaudio.te +127 -23
220 lines not on this page · raw message
qemu.te +2 -2
@@ -1,4 +1,4 @@ -policy_module(qemu, 1.7.1) +policy_module(qemu, 1.7.2) ######################################## #
@@ -96,7 +96,7 @@ ') optional_policy(` - pulseaudio_manage_home_files(qemu_t) + pulseaudio_manage_home(qemu_t) pulseaudio_stream_connect(qemu_t) ')
gpg.te line 285
Quoted 7 lines · Dominick Grift
manage_sock_files_pattern(gpg_pinentry_t, gpg_pinentry_tmp_t, gpg_pinentry_tmp_t)userdom_user_tmp_filetrans(gpg_pinentry_t, gpg_pinentry_tmp_t, sock_file)gpg.te +0
-4- -manage_dirs_pattern(gpg_pinentry_t, gpg_pinentry_tmpfs_t, gpg_pinentry_tmpfs_t) -manage_files_pattern(gpg_pinentry_t, gpg_pinentry_tmpfs_t, gpg_pinentry_tmpfs_t) -fs_tmpfs_filetrans(gpg_pinentry_t, gpg_pinentry_tmpfs_t, { file dir })
Whoops that should not have been removed so readding that
Quoted 7 lines · Dominick Grift
The
pulseaudio_tmpfs_file_typeis assigned to all clients tmpfile file types separately with thepulseaudio_tmpfs_content()interface
pulseaudio_clientsatomatically get the access they need to pulseaudio tmpfs contentread and delete the content
I have a similar construction with alsa. One thing I am hoping to look into soon is a "What if /dev/shm was shm_tmpfs_t instead of tmpfs_t", would that make sense?
It would tighten the scope of such "wide" tmpfs file accesses.
Wkr,
Sven Vermeulen
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 13 lines · Sven Vermeulen
Quoted 7 lines · Dominick Grift
The
pulseaudio_tmpfs_file_typeis assigned to all clients tmpfile file types separately with thepulseaudio_tmpfs_content()interface
pulseaudio_clientsatomatically get the access they need to pulseaudio tmpfs contentread and delete the content
I have a similar construction with alsa. One thing I am hoping to look into soon is a "What if
/dev/shmwasshm_tmpfs_tinstead oftmpfs_t", would that make sense?
Quoted 6 lines
It would tighten the scope of such "wide" tmpfs file accesses.
Wkr, Sven Vermeulen _______________________________________________ refpolicy mailing list refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy
Or just shm_t. Since /tmp is now a tmpfs but we lable it tmpfs_t.
That would allow admins to create a new tmpfs for a specific use and prevent confined domains from useing it. Currently we have tmpfs on /run /dev and /tmp and they all have unigue labels, /dev/shm should problem also.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
iEYEARECAAYFAlCBl8IACgkQrlYvE4MpobPafwCfYbj+JgjuGJV1oGAKrRC6JCh/ sSoAmwa1eWx3uitdO3RaG7rQRxuQWrAR
=yUl2
-----END PGP SIGNATURE-----
Quoted 7 lines · Sven Vermeulen
Quoted 6 lines · Dominick Grift
The
pulseaudio_tmpfs_file_typeis assigned to all clients tmpfile file types separately with thepulseaudio_tmpfs_content()interface
pulseaudio_clientsatomatically get the access they need to pulseaudio tmpfs content
Quoted 7 lines
Quoted 1 line
read and delete the content
I have a similar construction with alsa. One thing I am hoping to look into soon is a "What if
/dev/shmwasshm_tmpfs_tinstead oftmpfs_t", would that make sense?It would tighten the scope of such "wide" tmpfs file accesses.
pulseaudio clients create that pulse-shm file in /dev/shm with a private type, i do not see how this would help?
programs that use pulse and that run in the userdomain create those files with user_tmpfs_t
So all they need with regard to tmpfs_t is search tmpfs_t dirs, add and remove dir entries from tmpfs_t dirs and get attributes of tmpfs_t filesystems
Quoted 6 lines
Wkr,
Sven Vermeulen
_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy
Quoted 9 lines · Dominick Grift
Quoted 5 lines
I have a similar construction with alsa. One thing I am hoping to look into soon is a "What if
/dev/shmwasshm_tmpfs_tinstead oftmpfs_t", would that make sense?It would tighten the scope of such "wide" tmpfs file accesses.
pulseaudio clients create that pulse-shm file in
/dev/shmwith a private type, i do not see how this would help?
Quoted 6 lines
programs that use pulse and that run in the userdomain create those files with
user_tmpfs_tSo all they need with regard to
tmpfs_tis searchtmpfs_tdirs, add and remove dir entries fromtmpfs_tdirs and get attributes oftmpfs_tfilesystems
It's mainly for reducing the scope. If pulseaudio clients automatically have their tmpfs types be writeable by other pulseaudio clients, then also non-shm related tmpfs files are affected by this.
If we'd use a specific type for shared memory (like shm_t) then other tmpfs files are not "opened up".
It's a fairly intrusive change for a small gain, I understand (many policies will need to be adapted for this, whereas there aren't that many tmpfs locations on a system I think that are actually labeled as tmpfs_t). Hence the "look into" part of the suggestion ;)
Wkr,
Sven Vermeulen
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/19/2012 02:13 PM, Dominick Grift wrote:
They are allowed to create files in the tmpfs.
Imagine a third party product creates a tmpfs in /dev/mytmpfs
Currently confined apps and users are allowed to create files in that directory, if we gave access only to shm_t then this tmpfs would be protected.
Of course the third party could label it's tmpfs something different, but
then they would need to know about SELinux.
Just a thought.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
iEYEARECAAYFAlCBvWEACgkQrlYvE4MpobNLMACfcrm3eZjg1Q9Y8LlGzWL7opv8 h+EAoL/64RCTl7fsUSKUY7Yqdw1MCcKG
=Nn6r
-----END PGP SIGNATURE-----
Quoted 4 lines · Daniel J Walsh
On 10/19/2012 02:13 PM, Dominick Grift wrote:
They are allowed to create files in the tmpfs.
Quoted 8 lines
Imagine a third party product creates a tmpfs in
/dev/mytmpfsCurrently confined apps and users are allowed to create files in that directory, if we gave access only to
shm_tthen this tmpfs would be protected.
Of course the third party could label it's tmpfs something different, but
then they would need to know about SELinux.Just a thought.
Sure i am ok with that idea. go ahead and implement it ;)
I am currently more interested in applicable feed back, suggestions and comments on the patch in the topic though :)
Quoted 1 line · Dominick Grift
I am currently trying to port the pulseaudio policy module with changes
If i do not get any comments, suggestions or questions then i guess this is good to implement