Skip to content

Commit f2b3fc4

Browse files
stefanbergermimizohar
authored andcommitted
evm: Implement per signature type decision in security_inode_copy_up_xattr
To support "portable and immutable signatures" on otherwise unsupported filesystems, determine the EVM signature type by the content of a file's xattr. If the file has the appropriate signature type then allow it to be copied up. All other signature types are discarded as before. "Portable and immutable" EVM signatures can be copied up by stacked file- system since the metadata their signature covers does not include file- system-specific data such as a file's inode number, generation, and UUID. Co-developed-by: Mimi Zohar <[email protected]> Signed-off-by: Stefan Berger <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 3253804 commit f2b3fc4

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

security/integrity/evm/evm_main.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -948,9 +948,34 @@ static void evm_inode_post_setattr(struct mnt_idmap *idmap,
948948

949949
static int evm_inode_copy_up_xattr(struct dentry *src, const char *name)
950950
{
951-
if (strcmp(name, XATTR_NAME_EVM) == 0)
952-
return 1; /* Discard */
953-
return -EOPNOTSUPP;
951+
struct evm_ima_xattr_data *xattr_data = NULL;
952+
int rc;
953+
954+
if (strcmp(name, XATTR_NAME_EVM) != 0)
955+
return -EOPNOTSUPP;
956+
957+
/* first need to know the sig type */
958+
rc = vfs_getxattr_alloc(&nop_mnt_idmap, src, XATTR_NAME_EVM,
959+
(char **)&xattr_data, 0, GFP_NOFS);
960+
if (rc <= 0)
961+
return -EPERM;
962+
963+
if (rc < offsetof(struct evm_ima_xattr_data, type) +
964+
sizeof(xattr_data->type))
965+
return -EPERM;
966+
967+
switch (xattr_data->type) {
968+
case EVM_XATTR_PORTABLE_DIGSIG:
969+
rc = 0; /* allow copy-up */
970+
break;
971+
case EVM_XATTR_HMAC:
972+
case EVM_IMA_XATTR_DIGSIG:
973+
default:
974+
rc = 1; /* discard */
975+
}
976+
977+
kfree(xattr_data);
978+
return rc;
954979
}
955980

956981
/*

0 commit comments

Comments
 (0)