Skip to content

Commit 9ba2a2c

Browse files
dwindsorgregkh
authored andcommitted
selinux: don't reserve xattr slot when we won't fill it
commit 1e5a8ee upstream. Move lsm_get_xattr_slot() below the SBLABEL_MNT check so we don't leave a NULL-named slot in the array when returning -EOPNOTSUPP; filesystem initxattrs() callbacks stop iterating at the first NULL ->name, silently dropping xattrs installed by later LSMs. Cc: stable@vger.kernel.org Signed-off-by: David Windsor <dwindsor@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7eca71f commit 9ba2a2c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

security/selinux/hooks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2965,7 +2965,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
29652965
{
29662966
const struct cred_security_struct *crsec = selinux_cred(current_cred());
29672967
struct superblock_security_struct *sbsec;
2968-
struct xattr *xattr = lsm_get_xattr_slot(xattrs, xattr_count);
2968+
struct xattr *xattr;
29692969
u32 newsid, clen;
29702970
u16 newsclass;
29712971
int rc;
@@ -2991,6 +2991,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
29912991
!(sbsec->flags & SBLABEL_MNT))
29922992
return -EOPNOTSUPP;
29932993

2994+
xattr = lsm_get_xattr_slot(xattrs, xattr_count);
29942995
if (xattr) {
29952996
rc = security_sid_to_context_force(newsid,
29962997
&context, &clen);

0 commit comments

Comments
 (0)