Support loopback mounts
Hello,
currently refpolicy seems not to support loopback mounts (mounts of ordinary files instead of block devices, for example used by squashfs). There's the type mount_loopback_t, but the currently granted permissions don't suffice.
The first patch isn't strictly neccessary, however it's useful for my application scenario, might also be useful for others and doesn't harm security. The neccessary permissions are added by the second and the third patch.
Regards,
Luis Ressel
PATCH 1/3 Allow mount_t to follow mount_loopback_t symlinks
This is useful for some application scenarios and doesn't harm security.
--- policy/modules/system/mount.te | 1 + 1 file changed, 1 insertion(+)
policy/modules/system/mount.te +1 -0
@@ -44,6 +44,7 @@ application_domain(unconfined_mount_t, mount_exec_t) 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; +allow mount_t mount_loopback_t:lnk_file read_file_perms; 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 1/3 Allow mount_t to follow mount_loopback_t symlinks
Quoted 10 lines · Luis Ressel
This is useful for some application scenarios and doesn't harm security.
--- policy/modules/system/mount.te | 1 + 1 file changed, 1 insertion(+)policy/modules/system/mount.te +0
-0
policy/modules/system/mount.te application_domain(unconfined_mount_t, mount_exec_t) · line 50
Quoted 7 lines
policy/modules/system/mount.te +1
-0@@ -44,6 +44,7 @@ application_domain(unconfined_mount_t, mount_exec_t) 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; +allow mount_t mount_loopback_t:lnk_file read_file_perms; allow mount_t mount_tmp_t:file manage_file_perms; allow mount_t mount_tmp_t:dir manage_dir_perms;
We generally prefer not to specially label symlinks. They don't have the security properties of the object the point to, and the permissions are checked normally on the target.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com
PATCH 1/3 Allow mount_t to follow mount_loopback_t symlinks
Quoted 3 lines · On Fri, 31 Jan 2014 22:28:15 -0500 "Christopher J. PeBenito"…
We generally prefer not to specially label symlinks. They don't have the security properties of the object the point to, and the permissions are checked normally on the target.
My application case is that I'm mounting a regularily updated squashfs image. The filename of this image includes a timestamp, so I'm using a symlink; otherwise I'd have to update fstab each time the filename changes.
I understand that labeling symlinks is uncommon, but in this particular case it seems like the best solution.
The change clearly doesn't harm security, so I choose to push it upstream. Perhaps others are also using this scheme, but I'm sure it's not too common, so I'd also be okay with just applying this patch locally.
--
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/52667ce1/attachment.bin
PATCH 2/3 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
@@ -78,6 +78,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) +rw_chr_files_pattern(mount_t, device_t, loop_control_device_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 2/3 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 84
Quoted 7 lines
policy/modules/system/mount.te +1
-0@@ -78,6 +78,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) +rw_chr_files_pattern(mount_t, device_t, loop_control_device_t) dev_dontaudit_getattr_all_chr_files(mount_t) dev_dontaudit_getattr_memory_dev(mount_t) dev_getattr_sound_dev(mount_t)
A proper interface in the devices modules needs to be created to support this access.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com
PATCH 3/3 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 | 4 ++++ 1 file changed, 4 insertions(+)
policy/modules/kernel/kernel.te +4 -0
@@ -287,6 +287,10 @@ files_list_etc(kernel_t) files_list_home(kernel_t) files_read_usr_files(kernel_t) +allow kernel_t mount_t:fd use; +allow kernel_t mount_loopback_t:fd use; +allow kernel_t mount_loopback_t:file read_file_perms; + mcs_process_set_categories(kernel_t) mls_process_read_up(kernel_t)
Signature · 1 line
1.8.5.3
PATCH 3/3 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 | 4 ++++ 1 file changed, 4 insertions(+)policy/modules/kernel/kernel.te +0
-0
policy/modules/kernel/kernel.te files_list_etc(kernel_t) · line 290
Quoted 4 lines
policy/modules/kernel/kernel.te +1
-0@@ -287,6 +287,10 @@ files_list_etc(kernel_t) files_list_home(kernel_t) files_read_usr_files(kernel_t) +allow kernel_t mount_t:fd use;
The interface that exists in the mount module should be used for this access.
policy/modules/kernel/kernel.te files_list_etc(kernel_t) · line 291
Quoted 1 line
policy/modules/kernel/kernel.te +1
-0+allow kernel_t mount_loopback_t:fd use;
mount_loopback_t is not a process so this has no effect.
policy/modules/kernel/kernel.te files_list_etc(kernel_t) · line 292
Quoted 1 line
policy/modules/kernel/kernel.te +1
-0+allow kernel_t mount_loopback_t:file read_file_perms;
An interface needs to be created and used for this access.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com
PATCH 3/3 Grant kernel_t necessary permissions for loopback mounts
Quoted 1 line · On Fri, 31 Jan 2014 22:32:44 -0500 "Christopher J. PeBenito"…
mount_loopback_tis not a process so this has no effect.
When originally developing the policy, this definitively showed up in my audit log. I removed it now - and it doesn't show up anymore. I don't know what exactly was going on there.
I'll send an updated patch series.
--
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/4a58d63e/attachment.bin