Skip to content

Commit ebd4250

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 c2efc49 commit ebd4250

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
@@ -2903,7 +2903,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
29032903
{
29042904
const struct task_security_struct *tsec = selinux_cred(current_cred());
29052905
struct superblock_security_struct *sbsec;
2906-
struct xattr *xattr = lsm_get_xattr_slot(xattrs, xattr_count);
2906+
struct xattr *xattr;
29072907
u32 newsid, clen;
29082908
int rc;
29092909
char *context;
@@ -2930,6 +2930,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
29302930
!(sbsec->flags & SBLABEL_MNT))
29312931
return -EOPNOTSUPP;
29322932

2933+
xattr = lsm_get_xattr_slot(xattrs, xattr_count);
29332934
if (xattr) {
29342935
rc = security_sid_to_context_force(newsid,
29352936
&context, &clen);

0 commit comments

Comments
 (0)