ceph: only set CEPH_I_SEC_INITED if we got a MAC label
authorJeff Layton <jlayton@kernel.org>
Tue, 6 Aug 2019 14:41:40 +0000 (10:41 -0400)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 16 Sep 2019 10:06:25 +0000 (12:06 +0200)
__ceph_getxattr will set the CEPH_I_SEC_INITED flag whenever it gets
any xattr that starts with "security.". We only want to set that flag
when fetching the MAC label for the currently-active LSM, however.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/xattr.c

index 5c608caf0190b2e5d65c6e16195f35c84876e03f..410eaf1ba2112e6f3fc75dfbaeab32573fdb9e61 100644 (file)
@@ -892,7 +892,8 @@ ssize_t __ceph_getxattr(struct inode *inode, const char *name, void *value,
        memcpy(value, xattr->val, xattr->val_len);
 
        if (current->journal_info &&
-           !strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN))
+           !strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) &&
+           security_ismaclabel(name + XATTR_SECURITY_PREFIX_LEN))
                ci->i_ceph_flags |= CEPH_I_SEC_INITED;
 out:
        spin_unlock(&ci->i_ceph_lock);