mirror of
https://github.com/torvalds/linux.git
synced 2026-10-23 23:51:02 +02:00
selinux: preserve NATIVE_LABELS on already-initialized sb in set_mnt_opts
When an NFSv4 filesystem exported with security_label is mounted a second time, sget_fc() returns the existing superblock and nfs_get_root() calls security_sb_set_mnt_opts() again on it. Since the superblock is already SB_INITIALIZED, selinux_set_mnt_opts() takes an early exit without setting SECURITY_LSM_NATIVE_LABELS in *set_kern_flags. nfs_get_root() then sees kflags without SECURITY_LSM_NATIVE_LABELS set and clears NFS_CAP_SECURITY_LABEL on the shared nfs_server, silently disabling per-file labeling for both the new and the original mount. Commit3815a245b5("security/selinux: fix SECURITY_LSM_NATIVE_LABELS on reused superblock") fixed the same problem in selinux_sb_clone_mnt_opts(). The reused-superblock path for a plain second mount now goes through sb_set_mnt_opts rather than sb_clone_mnt_opts, so it needs the same treatment: on both SE_SBINITIALIZED early exits, set SECURITY_LSM_NATIVE_LABELS in *set_kern_flags when the superblock was already using SECURITY_FS_USE_NATVE. Cc: stable@vger.kernel.org Closes: https://github.com/SELinuxProject/selinux-kernel/issues/69 Closes: https://github.com/SELinuxProject/selinux-kernel/issues/70 Closes: https://github.com/SELinuxProject/selinux-testsuite/issues/91 Closes: https://github.com/SELinuxProject/selinux-testsuite/issues/92 Fixes:eb9ae68650("SELinux: Add new labeling type native labels") Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
1ca924044b
commit
28b7260548
|
|
@ -690,8 +690,12 @@ static int selinux_set_mnt_opts(struct super_block *sb,
|
|||
* will be used for both mounts)
|
||||
*/
|
||||
if ((sbsec->flags & SE_SBINITIALIZED) && (sb->s_type->fs_flags & FS_BINARY_MOUNTDATA)
|
||||
&& !opts)
|
||||
&& !opts) {
|
||||
if ((kern_flags & SECURITY_LSM_NATIVE_LABELS) &&
|
||||
sbsec->behavior == SECURITY_FS_USE_NATIVE)
|
||||
*set_kern_flags |= SECURITY_LSM_NATIVE_LABELS;
|
||||
goto out;
|
||||
}
|
||||
|
||||
root_isec = backing_inode_security_novalidate(root);
|
||||
|
||||
|
|
@ -735,6 +739,9 @@ static int selinux_set_mnt_opts(struct super_block *sb,
|
|||
/* previously mounted with options, but not on this attempt? */
|
||||
if ((sbsec->flags & SE_MNTMASK) && !opts)
|
||||
goto out_double_mount;
|
||||
if ((kern_flags & SECURITY_LSM_NATIVE_LABELS) &&
|
||||
sbsec->behavior == SECURITY_FS_USE_NATIVE)
|
||||
*set_kern_flags |= SECURITY_LSM_NATIVE_LABELS;
|
||||
rc = 0;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user