From: guido@trentalancia.net (Guido Trentalancia) Date: Fri, 02 Sep 2016 16:11:19 +0200 Subject: [refpolicy] [PATCH] Improve tunable support for rw operations on noxattr fs / removable media Message-ID: <1472825479.21408.1.camel@trentalancia.net> To: refpolicy@oss.tresys.com List-Id: refpolicy.oss.tresys.com Improve the existing user domain template policy: - better support for the "user_rw_noexattrfile" boolean (enable write operations on filesystems that do not support extended attributes, such as FAT or cdrom filesystem); - add support for a new "user_exec_noexattrfile" boolean to control the execution of files from filesystems that do not support extended attributes (potentially dangerous); - add support for a new "user_write_removable" boolean which enables write operations on removable devices (such as external removable USB memory, USB mobile phones, etc). Note that devices might be removable but support extended attributes (Linux xattr filesystems on external USB mass storage devices), so two separate booleans are needed for optimal configuration flexibility. Writing to removable mass storage devices is a major cause of leakage of confidential information, so the new boolean defaults to false. Signed-off-by: Guido Trentalancia --- policy/modules/system/userdomain.if | 45 +++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) --- refpolicy-git-06082016-orig/policy/modules/system/userdomain.if 2016-09-02 15:56:29.649686667 +0200 +++ refpolicy-git-06082016/policy/modules/system/userdomain.if 2016-09-02 15:54:22.817915887 +0200 @@ -572,10 +572,30 @@ template(`userdom_common_user_template', dev_read_mouse($1_t) ') + tunable_policy(`user_rw_noexattrfile',` + fs_manage_noxattr_fs_files($1_t) + fs_manage_noxattr_fs_dirs($1_t) + ',` + fs_read_noxattr_fs_files($1_t) + ') + tunable_policy(`user_ttyfile_stat',` term_getattr_all_ttys($1_t) ') + tunable_policy(`user_write_removable',` + # Read/write floppies and other removable devices + storage_raw_read_removable_device($1_t) + storage_raw_write_removable_device($1_t) + # Read/write USB devices (e.g. external removable USB mass storage devices) + dev_rw_generic_usb_dev($1_t) + ',` + # Read floppies + storage_raw_read_removable_device($1_t) + # Read USB devices (e.g. external removable USB mass storage devices) + dev_read_generic_usb_dev($1_t) + ') + optional_policy(` alsa_home_filetrans_alsa_home($1_t, file, ".asoundrc") alsa_manage_home_files($1_t) @@ -1013,26 +1058,16 @@ template(`userdom_unpriv_user_template', files_exec_usr_files($1_t) - ifndef(`enable_mls',` - fs_exec_noxattr($1_t) - - tunable_policy(`user_rw_noexattrfile',` - fs_manage_noxattr_fs_files($1_t) - fs_manage_noxattr_fs_dirs($1_t) - # Write floppies - storage_raw_read_removable_device($1_t) - storage_raw_write_removable_device($1_t) - ',` - storage_raw_read_removable_device($1_t) - ') - ') - tunable_policy(`user_dmesg',` kernel_read_ring_buffer($1_t) ',` kernel_dontaudit_read_ring_buffer($1_t) ') + tunable_policy(`user_exec_noexattrfile',` + fs_exec_noxattr($1_t) + ') + # Allow users to run TCP servers (bind to ports and accept connection from # the same domain and outside users) disabling this forces FTP passive mode # and may change other protocols @@ -1214,13 +1249,6 @@ template(`userdom_admin_user_template',` userdom_manage_user_home_content_sockets($1_t) userdom_user_home_dir_filetrans_user_home_content($1_t, { dir file lnk_file fifo_file sock_file }) - tunable_policy(`user_rw_noexattrfile',` - fs_manage_noxattr_fs_files($1_t) - fs_manage_noxattr_fs_dirs($1_t) - ',` - fs_read_noxattr_fs_files($1_t) - ') - optional_policy(` postgresql_unconfined($1_t) ')