diff options
author | Roberto Sassu <roberto.sassu@huawei.com> | 2023-11-16 10:01:21 +0100 |
---|---|---|
committer | Casey Schaufler <casey@schaufler-ca.com> | 2024-01-24 14:06:26 -0800 |
commit | 9c82169208dde516510aaba6bbd8b13976690c5d (patch) | |
tree | 4eada326475bf3ca23f871e5730de4bb40fceb40 /security/smack/smack_lsm.c | |
parent | 6613476e225e090cc9aad49be7fa504e290dd33d (diff) | |
download | linux-9c82169208dde516510aaba6bbd8b13976690c5d.tar.gz linux-9c82169208dde516510aaba6bbd8b13976690c5d.tar.bz2 linux-9c82169208dde516510aaba6bbd8b13976690c5d.zip |
smack: Set SMACK64TRANSMUTE only for dirs in smack_inode_setxattr()
Since the SMACK64TRANSMUTE xattr makes sense only for directories, enforce
this restriction in smack_inode_setxattr().
Cc: stable@vger.kernel.org
Fixes: 5c6d1125f8db ("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>
Diffstat (limited to 'security/smack/smack_lsm.c')
-rw-r--r-- | security/smack/smack_lsm.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 0fdbf04cc258..72b371812a00 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -1314,7 +1314,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 |