Skip to content

Commit

Permalink
smack: Set SMACK64TRANSMUTE only for dirs in smack_inode_setxattr()
Browse files Browse the repository at this point in the history
[ Upstream commit 9c82169 ]

Since the SMACK64TRANSMUTE xattr makes sense only for directories, enforce
this restriction in smack_inode_setxattr().

Cc: stable@vger.kernel.org
Fixes: 5c6d112 ("Smack: Transmute labels on specified directories") # v2.6.38.x
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
robertosassu authored and gregkh committed Apr 3, 2024
1 parent e7a300c commit 9601f19
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion security/smack/smack_lsm.c
Expand Up @@ -1312,7 +1312,8 @@ static int smack_inode_setxattr(struct mnt_idmap *idmap,
check_star = 1;
} else if (strcmp(name, XATTR_NAME_SMACKTRANSMUTE) == 0) {
check_priv = 1;
if (size != TRANS_TRUE_SIZE ||
if (!S_ISDIR(d_backing_inode(dentry)->i_mode) ||
size != TRANS_TRUE_SIZE ||
strncmp(value, TRANS_TRUE, TRANS_TRUE_SIZE) != 0)
rc = -EINVAL;
} else
Expand Down

0 comments on commit 9601f19

Please sign in to comment.