policy/test_overlayfs.te: allow mounter to create whiteouts
Stephen Smalley
maintainerPATCH 1/1 policy/test_overlayfs.te: allow mounter to create whiteouts
This is required to pass the tests for kernels that include commit a3c751a50fe6 ("vfs: allow unprivileged whiteout creation"), which changed vfs_mknod() to permit whiteout creation without requiring CAP_MKNOD and then switched vfs_whiteout() to use vfs_mknod() rather than calling i_op->mknod() directly, which was originally done to avoid such checking. However, vfs_mknod() still calls the LSM hook and therefore applies SELinux checks on whiteout creation. Since vfs_whiteout() now calls vfs_mknod(), SELinux :chr_file create permission is now required for such whiteout creation by overlayfs. Skipping the LSM hook call or SELinux check entirely seems unsafe since we otherwise would never check whether the process was allowed to create a file in that label; even though the whiteout device cannot be read/written, it can be used as a channel wrt its existence and attributes.
See the discussion in:
https://lore.kernel.org/linux-fsdevel/[email protected]/
--- policy/test_overlayfs.te | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
policy/test_overlayfs.te +1 -1
@@ -88,7 +88,7 @@ manage_dirs_pattern(test_overlay_mounter_t, test_overlay_mounter_files_t, test_o # # Needed to remove a transition file # -allow test_overlay_mounter_t test_overlay_mounter_files_t:chr_file { getattr rename unlink }; +allow test_overlay_mounter_t test_overlay_mounter_files_t:chr_file { create getattr rename unlink }; allow test_overlay_mounter_t test_overlay_files_rwx_t:chr_file { manage_chr_file_perms rename unlink }; #
Signature · 1 line
2.23.3
Quoted 14 lines · Stephen Smalley
This is required to pass the tests for kernels that include commit
a3c751a50fe6("vfs: allow unprivileged whiteout creation"), which changedvfs_mknod()to permit whiteout creation without requiringCAP_MKNODand then switchedvfs_whiteout()to usevfs_mknod()rather than callingi_op->mknod()directly, which was originally done to avoid such checking. However,vfs_mknod()still calls the LSM hook and therefore applies SELinux checks on whiteout creation. Sincevfs_whiteout()now callsvfs_mknod(), SELinux :chr_file create permission is now required for such whiteout creation by overlayfs. Skipping the LSM hook call or SELinux check entirely seems unsafe since we otherwise would never check whether the process was allowed to create a file in that label; even though the whiteout device cannot be read/written, it can be used as a channel wrt its existence and attributes.
Quoted 7 lines
See the discussion in:
https://lore.kernel.org/linux-fsdevel/[email protected]/Signed-off-by Stephen Smalley <[email protected]>--- policy/test_overlayfs.te | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks, this looks good and fixes the failure for me.
policy/test_overlayfs.te manage_dirs_pattern(test_overlay_mounter_t, test_overlay_mounter_files_t, test_o · line 89
Quoted 8 lines
policy/test_overlayfs.te +0
-0@@ -88,7 +88,7 @@ manage_dirs_pattern(test_overlay_mounter_t, test_overlay_mounter_files_t, test_o # # Needed to remove a transition file
Just please also update this comment ("...to create and remove..." or similar).
Quoted 9 lines
policy/test_overlayfs.te +1
-2# -allow test_overlay_mounter_t test_overlay_mounter_files_t:chr_file { getattr rename unlink }; +allow test_overlay_mounter_t test_overlay_mounter_files_t:chr_file { create getattr rename unlink }; allow test_overlay_mounter_t test_overlay_files_rwx_t:chr_file { manage_chr_file_perms rename unlink }; # --2.23.3
Signature · 3 lines
Ondrej Mosnacek Software Engineer, Platform Security - SELinux kernel Red Hat, Inc.
Stephen Smalley
maintainerQuoted 28 lines · Ondrej Mosnacek
Quoted 14 lines · Stephen Smalley
This is required to pass the tests for kernels that include commit
a3c751a50fe6("vfs: allow unprivileged whiteout creation"), which changedvfs_mknod()to permit whiteout creation without requiringCAP_MKNODand then switchedvfs_whiteout()to usevfs_mknod()rather than callingi_op->mknod()directly, which was originally done to avoid such checking. However,vfs_mknod()still calls the LSM hook and therefore applies SELinux checks on whiteout creation. Sincevfs_whiteout()now callsvfs_mknod(), SELinux :chr_file create permission is now required for such whiteout creation by overlayfs. Skipping the LSM hook call or SELinux check entirely seems unsafe since we otherwise would never check whether the process was allowed to create a file in that label; even though the whiteout device cannot be read/written, it can be used as a channel wrt its existence and attributes.Quoted 7 lines
See the discussion in:
https://lore.kernel.org/linux-fsdevel/[email protected]/Signed-off-by Stephen Smalley <[email protected]>--- policy/test_overlayfs.te | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Thanks, this looks good and fixes the failure for me.
Quoted 1 line
Quoted 9 lines
policy/test_overlayfs.te manage_dirs_pattern(test_overlay_mounter_t, test_overlay_mounter_files_t, test_o · line 89
Quoted 7 lines
policy/test_overlayfs.te +0
-0@@ -88,7 +88,7 @@ manage_dirs_pattern(test_overlay_mounter_t, test_overlay_mounter_files_t, test_o # # Needed to remove a transition fileJust please also update this comment ("...to create and remove..." or similar).
That wouldn't be correct. The additional :chr_file create permission is needed to remove the transition file because removing a file from overlayfs creates a whiteout device file. It isn't to create the transition file.
Ondrej Mosnacek
Acked-byQuoted 39 lines · Stephen Smalley
Quoted 28 lines · Ondrej Mosnacek
Quoted 14 lines · Stephen Smalley
This is required to pass the tests for kernels that include commit
a3c751a50fe6("vfs: allow unprivileged whiteout creation"), which changedvfs_mknod()to permit whiteout creation without requiringCAP_MKNODand then switchedvfs_whiteout()to usevfs_mknod()rather than callingi_op->mknod()directly, which was originally done to avoid such checking. However,vfs_mknod()still calls the LSM hook and therefore applies SELinux checks on whiteout creation. Sincevfs_whiteout()now callsvfs_mknod(), SELinux :chr_file create permission is now required for such whiteout creation by overlayfs. Skipping the LSM hook call or SELinux check entirely seems unsafe since we otherwise would never check whether the process was allowed to create a file in that label; even though the whiteout device cannot be read/written, it can be used as a channel wrt its existence and attributes.Quoted 7 lines
See the discussion in:
https://lore.kernel.org/linux-fsdevel/[email protected]/Signed-off-by Stephen Smalley <[email protected]>--- policy/test_overlayfs.te | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Thanks, this looks good and fixes the failure for me.
Quoted 1 line
Quoted 9 lines
policy/test_overlayfs.te manage_dirs_pattern(test_overlay_mounter_t, test_overlay_mounter_files_t, test_o · line 89
Quoted 7 lines
policy/test_overlayfs.te +0
-0@@ -88,7 +88,7 @@ manage_dirs_pattern(test_overlay_mounter_t, test_overlay_mounter_files_t, test_o # # Needed to remove a transition fileJust please also update this comment ("...to create and remove..." or similar).
Quoted 4 lines
That wouldn't be correct. The additional :chr_file create permission is needed to remove the transition file because removing a file from overlayfs creates a whiteout device file. It isn't to create the transition file.
Ah, I see... In that case the patch is fine as-is, so:
Signature · 3 lines
Ondrej Mosnacek Software Engineer, Platform Security - SELinux kernel Red Hat, Inc.
Quoted 41 lines · Ondrej Mosnacek
Quoted 39 lines · Stephen Smalley
Quoted 37 lines · Ondrej Mosnacek
Quoted 14 lines · Stephen Smalley
This is required to pass the tests for kernels that include commit
a3c751a50fe6("vfs: allow unprivileged whiteout creation"), which changedvfs_mknod()to permit whiteout creation without requiringCAP_MKNODand then switchedvfs_whiteout()to usevfs_mknod()rather than callingi_op->mknod()directly, which was originally done to avoid such checking. However,vfs_mknod()still calls the LSM hook and therefore applies SELinux checks on whiteout creation. Sincevfs_whiteout()now callsvfs_mknod(), SELinux :chr_file create permission is now required for such whiteout creation by overlayfs. Skipping the LSM hook call or SELinux check entirely seems unsafe since we otherwise would never check whether the process was allowed to create a file in that label; even though the whiteout device cannot be read/written, it can be used as a channel wrt its existence and attributes.Quoted 7 lines
See the discussion in:
https://lore.kernel.org/linux-fsdevel/[email protected]/Signed-off-by Stephen Smalley <[email protected]>--- policy/test_overlayfs.te | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Thanks, this looks good and fixes the failure for me.
policy/test_overlayfs.te manage_dirs_pattern(test_overlay_mounter_t, test_overlay_mounter_files_t, test_o · line 89
Quoted 8 lines
policy/test_overlayfs.te +0
-0@@ -88,7 +88,7 @@ manage_dirs_pattern(test_overlay_mounter_t, test_overlay_mounter_files_t, test_o # # Needed to remove a transition fileJust please also update this comment ("...to create and remove..." or similar).
Quoted 8 lines
Quoted 4 lines
That wouldn't be correct. The additional :chr_file create permission is needed to remove the transition file because removing a file from overlayfs creates a whiteout device file. It isn't to create the transition file.
Ah, I see... In that case the patch is fine as-is, so:
Acked-by Ondrej Mosnacek <[email protected]>
This patch is now applied.
Signature · 3 lines
Ondrej Mosnacek Software Engineer, Platform Security - SELinux kernel Red Hat, Inc.