Skip to contentSkip to conversation

patch: clean up vmware

PATCH Thomas Bleher 3 participants 3 messages Sep 17, 2004 – Sep 24, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

After reading through the messy vmware policy I decided to clean it up a little. Result is below.

I tried to change as little functionality as possible. I replaced a few permissions by macros and created a vmware_domain() macro. With the old policy, vmware created tmpfiles with type tmp_t ==> changed to tmp_domain().
I also took the liberty to rename vmware_user_t to user_vmware_t. Typealiases for compatibility are included.

I do not have VMWare here so it would be nice if someone could test these changes to make sure nothing breaks.

Comments welcome,
Thomas

PS: Another note: there seems to be no benefit to having both user_vmware_conf_t and user_vmware_file_t as vmware has create_file_perms for both. So these can probably be coalesced into one type.

 domains/program/unused/vmware.te       |  114 ---------------------------
 file_contexts/program/vmware.fc        |    6 -
 macros/base_user_macros.te             |    1 
 macros/macros/program/vmware_macros.te |  135 +++++++++++++++++++++++++++++++++
 4 files changed, 142 insertions(+), 114 deletions(-)
Signature · 2 lines
http://www.cip.ifi.lmu.de/~bleher/selinux/ - my SELinux pages
GPG-Fingerprint: BC4F BB16 30D6 F253 E3EA  D09E C562 2BAE B2F4 ABE7
domains/program/unused/vmware.te +3 -111
diff -urN orig/domains/program/unused/vmware.te mod/domains/program/unused/vmware.te
@@ -8,6 +8,9 @@
 #
 # Domain is for the VMWare admin programs and daemons.
 # X-Debian-Packages:
+#
+# NOTE: The user vmware domain is provided separately in 
+# macros/program/vmware_macros.te
 # 
 # Next two domains are create by the daemon_domain() macro.
 # The vmware_t domain is for running VMWare daemons
@@ -16,11 +19,6 @@
 # quick hack making it privhome, should have a domain for each user in a macro
 daemon_domain(vmware, `, privhome')
 
-# Domain for the user applications to run in.
-type vmware_user_t, domain, privmem;
-in_user_role(vmware_user_t)
-role sysadm_r types vmware_user_t;
-
 #
 # The vmware_user_exec_t type is for the user programs.
 #
@@ -29,18 +27,9 @@
 # Type for vmware devices.
 type vmware_device_t, file_type, device_type, dev_fs;
 
-# Type for files in /var/run when a user starts VMWare
-type vmware_user_var_run_t, file_type, pidfile;
-
 # The sys configuration used for the /etc/vmware configuration files
 type vmware_sys_conf_t, file_type, sysadmfile;
 
-# The user file type is for files created when the user is running VMWare
-type vmware_user_file_t, homedirfile, file_type;
-
-# The user file type for the VMWare configuration files
-type vmware_user_conf_t, homedirfile, file_type;
-
 #########################################################################
 # Additional rules to start/stop VMWare
 #
@@ -73,7 +62,6 @@
 allow vmware_t self:capability { net_raw setuid };
 
 # Access to ttys
-allow vmware_t user_tty_device_t:chr_file rw_file_perms;
 allow vmware_t console_device_t:chr_file rw_file_perms;
 allow vmware_t sysadm_devpts_t:chr_file rw_file_perms;
 
@@ -94,99 +82,3 @@
 # Rules needed to shutdown VMWare
 allow vmware_t self:process { signal };
 
-#############################################################
-# User rules for running VMWare
-#
-# Transition to VMWare user domain
-domain_auto_trans(user_t, vmware_user_exec_t, vmware_user_t)
-can_exec(vmware_user_t, vmware_user_exec_t)
-uses_shlib(vmware_user_t)
-file_type_auto_trans(vmware_user_t, var_run_t, vmware_user_var_run_t, file)
-
-general_domain_access(vmware_user_t);
-
-# Capabilities needed by VMWare for the user execution. This seems a 
-# bit too much, so be careful.
-allow vmware_user_t self:capability { dac_override setgid sys_nice sys_resource setuid sys_admin sys_rawio };
-
-# Access to ttys
-allow vmware_user_t vmware_device_t:chr_file rw_file_perms;
-allow vmware_user_t tty_device_t:chr_file rw_file_perms;
-allow vmware_user_t user_tty_device_t:chr_file rw_file_perms;
-allow vmware_user_t local_login_t:fd use;
-
-# Access /proc
-r_dir_file(vmware_user_t, proc_t)
-
-# Access to some files in the user home directory
-r_dir_file(vmware_user_t, user_home_t)
-
-# Access to runtime files for user
-allow vmware_user_t vmware_user_file_t:dir rw_dir_perms;
-allow vmware_user_t vmware_user_file_t:file create_file_perms;
-allow vmware_user_t vmware_user_conf_t:file create_file_perms;
-
-# Allow read access to /etc/vmware and /usr/lib/vmware configuration files
-r_dir_file(vmware_user_t, vmware_sys_conf_t)
-
-# Allow vmware_user_t to read/write files in the tmp dir
-allow vmware_user_t tmp_t:dir create_dir_perms;
-allow vmware_user_t tmp_t:file create_file_perms;
-allow vmware_user_t tmp_t:file { execute };
-
-# Allow read access to several paths
-r_dir_file(vmware_user_t, etc_t)
-allow vmware_user_t etc_runtime_t:file r_file_perms;
-allow vmware_user_t device_t:dir r_dir_perms;
-allow vmware_user_t var_t:dir r_dir_perms;
-allow vmware_user_t tmpfs_t:file rw_file_perms;
-
-# Allow vmware to write to ~/.vmware
-allow vmware_user_t vmware_user_file_t:dir rw_dir_perms;
-allow vmware_user_t vmware_user_file_t:file create_file_perms;
-
-#
-# This is bad; VMWare needs execute permission to the .cfg file for the
-# configuration to run.
-#
-allow vmware_user_t vmware_user_conf_t:file execute;
-
-# Access X11 config files
-allow vmware_user_t lib_t:file r_file_perms;
-
-# Access components of VMWare in /usr/lib/vmware/bin by default
-allow vmware_user_t bin_t:dir r_dir_perms;
-
-# Allow access to lp port (Need to create an lp device domain )
-allow vmware_user_t device_t:chr_file r_file_perms;
-
-# Allow access to /dev/mem
-allow vmware_user_t memory_device_t:chr_file { read write };
-
-# Allow access to mouse
-allow vmware_user_t mouse_device_t:chr_file r_file_perms;
-
-# Allow access the sound device 
-allow vmware_user_t sound_device_t:chr_file { ioctl write };
-
-# Allow removable media and devices
-allow vmware_user_t removable_device_t:blk_file r_file_perms;
-allow vmware_user_t removable_device_t:lnk_file { read };
-
-# Allow access to the real time clock device
-allow vmware_user_t clock_device_t:chr_file { read };
-
-# Allow to attach to Xserver, and Xserver to attach back
-ifdef(`gnome-pty-helper.te', `
-allow vmware_user_t user_gph_t:fd use;
-')
-ifdef(`startx.te', `
-allow vmware_user_t user_xserver_tmp_t:sock_file { unlink write };
-allow vmware_user_t user_xserver_tmp_t:dir { search };
-allow vmware_user_t user_xserver_t:unix_stream_socket { connectto };
-allow user_xserver_t vmware_user_t:shm r_shm_perms;
-allow user_xserver_t vmware_user_t:fd use;
-')
-
-# Allow filesystem read access
-allow vmware_user_t fs_t:filesystem { getattr };
file_contexts/program/vmware.fc +3 -3
diff -urN orig/file_contexts/program/vmware.fc mod/file_contexts/program/vmware.fc
@@ -37,6 +37,6 @@
 # The rules below assume that the user VMWare virtual disks are in the
 # ~/vmware, and the preferences and license files are in ~/.vmware.
 #
-HOME_DIR/\.vmware(/.*)?	system_u:object_r:vmware_ROLE_file_t
-HOME_DIR/\vmware(/.*)?	system_u:object_r:vmware_ROLE_file_t
-HOME_DIR/\vmware[^/]*/.*\.cfg	--	system_u:object_r:vmware_ROLE_conf_t
+HOME_DIR/\.vmware(/.*)?	system_u:object_r:ROLE_vmware_file_t
+HOME_DIR/\vmware(/.*)?	system_u:object_r:ROLE_vmware_file_t
+HOME_DIR/\vmware[^/]*/.*\.cfg	--	system_u:object_r:ROLE_vmware_conf_t
macros/base_user_macros.te +1 -0
diff -urN orig/macros/base_user_macros.te mod/macros/base_user_macros.te
@@ -158,6 +158,7 @@
 ifdef(`irc.te', `irc_domain($1)')
 ifdef(`using_spamassassin', `spamassassin_domain($1)')
 ifdef(`uml.te', `uml_domain($1)')
+ifdef(`vmware.te', `vmware_domain($1)')
 
 # Instantiate a derived domain for user cron jobs.
 ifdef(`crond.te', `crond_domain($1)')
macros/macros/program/vmware_macros.te +135 -0

135 lines not on this page · raw message

#1 lore raw
Quoted 2 lines · Thomas Bleher

After reading through the messy vmware policy I decided to clean it up a little. Result is below.

The changes are so great that patches don't work well. I've made a few modifications to your policy and attached an archive of it.

I think that defining vmware_t is a bad idea. I think that we want system_vmware_t to be used for vmware sessions launched by the server and have the same base macro used as for user_vmware_t.

Your work is good and is a significant enough improvement to be worth merging now. But we need to go further to get the full functionality.

Also please keep in mind that some people may want to have multiple VMware sessions isolated from each other which are launched from the same user role. Maybe having two parameters to the vmware_domain() macro is the correct thing to do, one to specify the source role and one part of the name for the target domain.

Signature · 4 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page
#2 lore raw

Merged.

I also added:

base_user_macros.te +1 -4
diff -u -r1.24 base_user_macros.te
@@ -167,10 +167,7 @@
 # Instantiate a derived domain for user cron jobs.
 ifdef(`crond.te', `crond_domain($1)')
 
-ifdef(`vmware.te', `
-# probably should have a separate domain for each user
-file_type_auto_trans(vmware_user_t, $1_home_dir_t, vmware_user_file_t)
-')
+ifdef(`vmware.te', `vmware_domain($1)')
 
 if (user_direct_mouse) {
 # Read the mouse.
Quoted 20 lines · Russell Coker
Quoted 2 lines · Thomas Bleher

After reading through the messy vmware policy I decided to clean it up a little. Result is below.

The changes are so great that patches don't work well. I've made a few modifications to your policy and attached an archive of it.

I think that defining vmware_t is a bad idea. I think that we want system_vmware_t to be used for vmware sessions launched by the server and have the same base macro used as for user_vmware_t.

Your work is good and is a significant enough improvement to be worth merging now. But we need to go further to get the full functionality.

Also please keep in mind that some people may want to have multiple VMware sessions isolated from each other which are launched from the same user role. Maybe having two parameters to the vmware_domain() macro is the correct thing to do, one to specify the source role and one part of the name for the target domain.

Signature · 7 lines
James Carter <[email protected]>
National Security Agency

--
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.