Skip to content

Commit 3a3d8fc

Browse files
robertosassucschaufler
authored andcommitted
smack: Retrieve transmuting information in smack_inode_getsecurity()
Enhance smack_inode_getsecurity() to retrieve the value for SMACK64TRANSMUTE from the inode security blob, similarly to SMACK64. This helps to display accurate values in the situation where the security labels come from mount options and not from xattrs. Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
1 parent ac9a786 commit 3a3d8fc

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

security/smack/smack_lsm.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,10 +1463,19 @@ static int smack_inode_getsecurity(struct mnt_idmap *idmap,
14631463
struct super_block *sbp;
14641464
struct inode *ip = inode;
14651465
struct smack_known *isp;
1466+
struct inode_smack *ispp;
1467+
size_t label_len;
1468+
char *label = NULL;
14661469

1467-
if (strcmp(name, XATTR_SMACK_SUFFIX) == 0)
1470+
if (strcmp(name, XATTR_SMACK_SUFFIX) == 0) {
14681471
isp = smk_of_inode(inode);
1469-
else {
1472+
} else if (strcmp(name, XATTR_SMACK_TRANSMUTE) == 0) {
1473+
ispp = smack_inode(inode);
1474+
if (ispp->smk_flags & SMK_INODE_TRANSMUTE)
1475+
label = TRANS_TRUE;
1476+
else
1477+
label = "";
1478+
} else {
14701479
/*
14711480
* The rest of the Smack xattrs are only on sockets.
14721481
*/
@@ -1488,13 +1497,18 @@ static int smack_inode_getsecurity(struct mnt_idmap *idmap,
14881497
return -EOPNOTSUPP;
14891498
}
14901499

1500+
if (!label)
1501+
label = isp->smk_known;
1502+
1503+
label_len = strlen(label);
1504+
14911505
if (alloc) {
1492-
*buffer = kstrdup(isp->smk_known, GFP_KERNEL);
1506+
*buffer = kstrdup(label, GFP_KERNEL);
14931507
if (*buffer == NULL)
14941508
return -ENOMEM;
14951509
}
14961510

1497-
return strlen(isp->smk_known);
1511+
return label_len;
14981512
}
14991513

15001514

0 commit comments

Comments
 (0)