selinux: access superblock_security_struct in LSM blob way
authorGONG, Ruiqi <gongruiqi1@huawei.com>
Tue, 25 Jan 2022 07:11:33 +0000 (15:11 +0800)
committerPaul Moore <paul@paul-moore.com>
Tue, 25 Jan 2022 23:46:04 +0000 (18:46 -0500)
LSM blob has been involved for superblock's security struct. So fix the
remaining direct access to sb->s_security by using the LSM blob
mechanism.

Fixes: 08abe46b2cfc ("selinux: fall back to SECURITY_FS_USE_GENFS if no xattr support")
Fixes: 69c4a42d72eb ("lsm,selinux: add new hook to compare new mount to an existing mount")
Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/hooks.c

index 5b6895e4fc29eb66859a3d6941b8a0f2df408942..a0243bae842380bd35e256742a55fec35632009f 100644 (file)
@@ -479,7 +479,7 @@ static int selinux_is_sblabel_mnt(struct super_block *sb)
 
 static int sb_check_xattr_support(struct super_block *sb)
 {
-       struct superblock_security_struct *sbsec = sb->s_security;
+       struct superblock_security_struct *sbsec = selinux_superblock(sb);
        struct dentry *root = sb->s_root;
        struct inode *root_inode = d_backing_inode(root);
        u32 sid;
@@ -2647,7 +2647,7 @@ free_opt:
 static int selinux_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts)
 {
        struct selinux_mnt_opts *opts = mnt_opts;
-       struct superblock_security_struct *sbsec = sb->s_security;
+       struct superblock_security_struct *sbsec = selinux_superblock(sb);
        u32 sid;
        int rc;