Updated loopback mount patches
This patch series is an updated version of my recent proposal and incorporates the feedback by Chris PeBenito. I haven't bumped the module versions, since I wasn't sure what to bump (only mount, or also kernel?).
--
Luis Ressel <[email protected]>
GPG fpr: F08D 2AF6 655E 25DE 52BC E53D 08F5 7F90 3029 B5BD
PATCH 1/4 kernel/devices.if: Add dev_rw_loop_control interface
--- policy/modules/kernel/devices.if | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
policy/modules/kernel/devices.if +18 -0
@@ -2378,6 +2378,24 @@ interface(`dev_rw_lirc',` ###################################### ## <summary> +## Read and write the loop-control device. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`dev_rw_loop_control',` + gen_require(` + type device_t, loop_control_device_t; + ') + + rw_chr_files_pattern($1, device_t, loop_control_device_t) +') + +###################################### +## <summary> ## Automatic type transition to the type ## for lirc device nodes when created in /dev. ## </summary>
Signature · 1 line
1.8.5.3
PATCH 1/4 kernel/devices.if: Add dev_rw_loop_control interface
Quoted 23 lines · Luis Ressel
--- policy/modules/kernel/devices.if | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)policy/modules/kernel/devices.if +11
-0@@ -2378,6 +2378,24 @@ interface(`dev_rw_lirc',` ###################################### ## <summary> +## Read and write the loop-control device. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`dev_rw_loop_control',` + gen_require(` + type device_t, loop_control_device_t;
policy/modules/kernel/devices.if interface(`dev_rw_lirc',` · line 2401
Quoted 10 lines
policy/modules/kernel/devices.if +7
-0+ ') + + rw_chr_files_pattern($1, device_t, loop_control_device_t) +') + +###################################### +## <summary> ## Automatic type transition to the type ## for lirc device nodes when created in /dev. ## </summary>
Merged.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com
PATCH 2/4 system/mount.if: Add mount_read_mount_loopback interface
In reply to Luis Ressel--- policy/modules/system/mount.if | 18 ++++++++++++++++++ policy/modules/system/mount.te | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-)
policy/modules/system/mount.if +18 -0
@@ -173,3 +173,21 @@ interface(`mount_run_unconfined',` mount_domtrans_unconfined($1) role $2 types unconfined_mount_t; ') + +######################################## +## <summary> +## Read mount_loopback files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`mount_read_mount_loopback',` + gen_require(` + type mount_t; + ') + + allow $1 mount_loopback_t:file read_file_perms; +')
policy/modules/system/mount.te +1 -1
@@ -43,7 +43,7 @@ application_domain(unconfined_mount_t, mount_exec_t) # setuid/setgid needed to mount cifs allow mount_t self:capability { ipc_lock sys_rawio sys_admin dac_override chown sys_tty_config setuid setgid }; -allow mount_t mount_loopback_t:file read_file_perms; +mount_read_mount_loopback(mount_t) allow mount_t mount_tmp_t:file manage_file_perms; allow mount_t mount_tmp_t:dir manage_dir_perms;
Signature · 1 line
1.8.5.3
PATCH 2/4 system/mount.if: Add mount_read_mount_loopback interface
Quoted 36 lines · Luis Ressel
--- policy/modules/system/mount.if | 18 ++++++++++++++++++ policy/modules/system/mount.te | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-)policy/modules/system/mount.if +18
-0@@ -173,3 +173,21 @@ interface(`mount_run_unconfined',` mount_domtrans_unconfined($1) role $2 types unconfined_mount_t; ') + +######################################## +## <summary> +## Read mount_loopback files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`mount_read_mount_loopback',` + gen_require(` + type mount_t; + ') + + allow $1 mount_loopback_t:file read_file_perms; +')policy/modules/system/mount.te +0
-0
policy/modules/system/mount.te application_domain(unconfined_mount_t, mount_exec_t) · line 49
Quoted 8 lines
policy/modules/system/mount.te +1
-1@@ -43,7 +43,7 @@ application_domain(unconfined_mount_t, mount_exec_t) # setuid/setgid needed to mount cifs allow mount_t self:capability { ipc_lock sys_rawio sys_admin dac_override chown sys_tty_config setuid setgid }; -allow mount_t mount_loopback_t:file read_file_perms; +mount_read_mount_loopback(mount_t) allow mount_t mount_tmp_t:file manage_file_perms; allow mount_t mount_tmp_t:dir manage_dir_perms;
Merged. I renamed the interface to mount_read_loopback_file().
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com
PATCH 3/4 Allow mount_t usage of /dev/loop-control
In reply to Luis ResselIf loopback devices are not pregenerated (kernel option CONFIG_BLK_DEV_LOOP_MIN_COUNT=0), mount needs to write to /dev/loop-control do create them dynamically when needed.
--- policy/modules/system/mount.te | 1 + 1 file changed, 1 insertion(+)
policy/modules/system/mount.te +1 -0
@@ -77,6 +77,7 @@ dev_list_all_dev_nodes(mount_t) dev_read_sysfs(mount_t) dev_dontaudit_write_sysfs_dirs(mount_t) dev_rw_lvm_control(mount_t) +dev_rw_loop_control(mount_t) dev_dontaudit_getattr_all_chr_files(mount_t) dev_dontaudit_getattr_memory_dev(mount_t) dev_getattr_sound_dev(mount_t)
Signature · 1 line
1.8.5.3
PATCH 3/4 Allow mount_t usage of /dev/loop-control
Quoted 12 lines · Luis Ressel
If loopback devices are not pregenerated (kernel option
CONFIG_BLK_DEV_LOOP_MIN_COUNT=0), mount needs to write to/dev/loop-controldo create them dynamically when needed.--- policy/modules/system/mount.te | 1 + 1 file changed, 1 insertion(+)policy/modules/system/mount.te +0
-0
policy/modules/system/mount.te dev_list_all_dev_nodes(mount_t) · line 83
Quoted 7 lines
policy/modules/system/mount.te +1
-0@@ -77,6 +77,7 @@ dev_list_all_dev_nodes(mount_t) dev_read_sysfs(mount_t) dev_dontaudit_write_sysfs_dirs(mount_t) dev_rw_lvm_control(mount_t) +dev_rw_loop_control(mount_t) dev_dontaudit_getattr_all_chr_files(mount_t) dev_dontaudit_getattr_memory_dev(mount_t) dev_getattr_sound_dev(mount_t)
Merged.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com
PATCH 4/4 Grant kernel_t necessary permissions for loopback mounts
In reply to Luis ResselFor loopback mounts to work, the kernel requires access permissions to fd's passed in by mount and to the source files (labeled mount_loopback_t).
--- policy/modules/kernel/kernel.te | 3 +++ 1 file changed, 3 insertions(+)
policy/modules/kernel/kernel.te +3 -0
@@ -287,6 +287,9 @@ files_list_etc(kernel_t) files_list_home(kernel_t) files_read_usr_files(kernel_t) +mount_use_fds(kernel_t) +mount_read_mount_loopback(kernel_t) + mcs_process_set_categories(kernel_t) mls_process_read_up(kernel_t)
Signature · 1 line
1.8.5.3
PATCH 4/4 Grant kernel_t necessary permissions for loopback mounts
Quoted 11 lines · Luis Ressel
For loopback mounts to work, the kernel requires access permissions to fd's passed in by mount and to the source files (labeled
mount_loopback_t).--- policy/modules/kernel/kernel.te | 3 +++ 1 file changed, 3 insertions(+)policy/modules/kernel/kernel.te +0
-0
policy/modules/kernel/kernel.te files_list_etc(kernel_t) · line 295
Quoted 9 lines
policy/modules/kernel/kernel.te +3
-0@@ -287,6 +287,9 @@ files_list_etc(kernel_t) files_list_home(kernel_t) files_read_usr_files(kernel_t) +mount_use_fds(kernel_t) +mount_read_mount_loopback(kernel_t) + mcs_process_set_categories(kernel_t) mls_process_read_up(kernel_t)
Merged. I made these optional since they are from a higher layer.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com
For mounting my squashfs images (which don't contain xattrs, even though squashfs has support for those), I currently also need "allow mount_t unlabeled_t:filesystem relabelfrom;".
kernel/filesystem.te mentions a filesystem "squash", dating back to 2007. Since then, the name seems to have changed to "squashfs".
Most likely "sed -i s/squash/squashfs/g kernel/filesystem.te" will do. I haven't tested it, though (as I haven't managed yet to compile the whole policy manually).
--
Luis Ressel <[email protected]>
GPG fpr: F08D 2AF6 655E 25DE 52BC E53D 08F5 7F90 3029 B5BD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 966 bytes
Desc: not available
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20140201/d30ddd28/attachment.bin