Loop device handling with losetup
This patch series adds the permissions needed for losetup. losetup is a utility to bind files to loop devices. I reused mount_loopback_t as the type for files intended to be bound to such loop devices.
Regards,
Luis Ressel
PATCH 1/3 system/mount.if: Add mount_rw_loopback_files interface
--- policy/modules/system/mount.if | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
policy/modules/system/mount.if +18 -0
@@ -191,3 +191,21 @@ interface(`mount_read_loopback_files',` allow $1 mount_loopback_t:file read_file_perms; ') + +######################################## +## <summary> +## Read and write loopback filesystem image files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`mount_rw_loopback_files',` + gen_require(` + type mount_loopback_t; + ') + + allow $1 mount_loopback_t:file rw_file_perms; +')
Signature · 1 line
1.8.5.5
PATCH 2/3 system/fstools.if: Add fstools_use_fds interface
In reply to Luis Ressel--- policy/modules/system/fstools.if | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
policy/modules/system/fstools.if +18 -0
@@ -83,6 +83,24 @@ interface(`fstools_signal',` ######################################## ## <summary> +## Inherit fstools file descriptors. +## </summary> +## <param name="domain"> +## <summary> +## The type of the process performing this action. +## </summary> +## </param> +# +interface(`fstools_use_fds',` + gen_require(` + type fsadm_t; + ') + + allow $1 fsadm_t:fd use; +') + +######################################## +## <summary> ## Read fstools unnamed pipes. ## </summary> ## <param name="domain">
Signature · 1 line
1.8.5.5
PATCH 3/3 Add neccessary permissions for losetup
In reply to Luis ResselThis allows losetup to bind mount_loopback_t files to loop devices.
--- policy/modules/kernel/kernel.te | 2 ++ policy/modules/system/fstools.te | 4 ++++ 2 files changed, 6 insertions(+)
policy/modules/kernel/kernel.te +2 -0
@@ -317,6 +317,8 @@ optional_policy(` ') optional_policy(` + # loop devices + fsadm_use_fds(kernel_t) mount_use_fds(kernel_t) mount_read_loopback_files(kernel_t) ')
policy/modules/system/fstools.te +4 -0
@@ -53,6 +53,10 @@ logging_log_filetrans(fsadm_t, fsadm_log_t, file) # Enable swapping to files allow fsadm_t swapfile_t:file { rw_file_perms swapon }; +# losetup: bind mount_loopback_t files to loop devices +dev_rw_loop_control(fsadm_t) +mount_rw_loopback_files(fsadm_t) + kernel_read_system_state(fsadm_t) kernel_read_kernel_sysctls(fsadm_t) kernel_request_load_module(fsadm_t)
Signature · 1 line
1.8.5.5
PATCH 3/3 Add neccessary permissions for losetup
Quoted 11 lines · Luis Ressel
This allows losetup to bind
mount_loopback_tfiles to loop devices.--- policy/modules/kernel/kernel.te | 2 ++ policy/modules/system/fstools.te | 4 ++++ 2 files changed, 6 insertions(+)policy/modules/kernel/kernel.te +0
-0
policy/modules/kernel/kernel.te optional_policy(` · line 324
Quoted 8 lines
policy/modules/kernel/kernel.te +2
-0@@ -317,6 +317,8 @@ optional_policy(` ') optional_policy(` + # loop devices + fsadm_use_fds(kernel_t) mount_use_fds(kernel_t) mount_read_loopback_files(kernel_t) ')
While I doubt that any system would be missing mount, I could see a stateless system missing fsadm. This addition should be separated out into another optional.
policy/modules/system/fstools.te logging_log_filetrans(fsadm_t, fsadm_log_t, file) · line 58
Quoted 11 lines
policy/modules/system/fstools.te +3
-0@@ -53,6 +53,10 @@ logging_log_filetrans(fsadm_t, fsadm_log_t, file) # Enable swapping to files allow fsadm_t swapfile_t:file { rw_file_perms swapon }; +# losetup: bind mount_loopback_t files to loop devices +dev_rw_loop_control(fsadm_t) +mount_rw_loopback_files(fsadm_t)
These need to be moved to their correct place in the file.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com