const char *xattr_name,
void *xattr_value,
size_t xattr_value_len);
+int evm_fix_hmac(struct dentry *dentry, const char *xattr_name,
+ const char *xattr_value, size_t xattr_value_len);
int evm_inode_init_security(struct inode *inode, struct inode *dir,
const struct qstr *qstr, struct xattr *xattrs,
int *xattr_count);
{
return INTEGRITY_UNKNOWN;
}
+
+static inline int evm_fix_hmac(struct dentry *dentry, const char *xattr_name,
+ const char *xattr_value, size_t xattr_value_len)
+{
+ return -EOPNOTSUPP;
+}
#endif
static inline int evm_inode_init_security(struct inode *inode, struct inode *dir,
return true;
}
+/**
+ * evm_fix_hmac - Calculate the HMAC and add it to security.evm for fix mode
+ * @dentry: pointer to the affected dentry which doesn't yet have security.evm
+ * xattr
+ * @xattr_name: pointer to the affected extended attribute name
+ * @xattr_value: pointer to the new extended attribute value
+ * @xattr_value_len: pointer to the new extended attribute value length
+ *
+ * Expects to be called with i_mutex locked.
+ *
+ * Return: 0 on success, -EPERM/-ENOMEM/-EOPNOTSUPP on failure
+ */
+int evm_fix_hmac(struct dentry *dentry, const char *xattr_name,
+ const char *xattr_value, size_t xattr_value_len)
+
+{
+ if (!evm_fixmode || !evm_revalidate_status((xattr_name)))
+ return -EPERM;
+
+ if (!(evm_initialized & EVM_INIT_HMAC))
+ return -EPERM;
+
+ if (is_unsupported_hmac_fs(dentry))
+ return -EOPNOTSUPP;
+
+ return evm_update_evmxattr(dentry, xattr_name, xattr_value, xattr_value_len);
+}
+
/**
* evm_inode_post_setxattr - update 'security.evm' to reflect the changes
* @dentry: pointer to the affected dentry
xattr_value->type != EVM_IMA_XATTR_DIGSIG)) {
if (!ima_fix_xattr(dentry, iint))
status = INTEGRITY_PASS;
+ } else if (status == INTEGRITY_NOLABEL) {
+ if (!evm_fix_hmac(dentry, XATTR_NAME_IMA,
+ (const char *)xattr_value,
+ xattr_len))
+ status = INTEGRITY_PASS;
}
/*