11 #include <linux/module.h>
14 #include <linux/xattr.h>
15 #include <linux/magic.h>
21 static int __init default_appraise_setup(
char *
str)
23 if (
strncmp(str,
"off", 3) == 0)
25 else if (
strncmp(str,
"fix", 3) == 0)
30 __setup(
"ima_appraise=", default_appraise_setup);
64 struct dentry *dentry = file->f_dentry;
68 const char *
op =
"appraise_data";
69 char *
cause =
"unknown";
74 if (!inode->
i_op->getxattr)
86 cause =
"missing-hash";
96 cause =
"missing-HMAC";
98 cause =
"invalid-HMAC";
102 switch (xattr_value->
type) {
107 cause =
"invalid-hash";
110 xattr_value,
sizeof(*xattr_value));
121 xattr_value->
digest, rc - 1,
127 cause =
"invalid-signature";
135 cause =
"unknown-ima-data";
144 ima_fix_xattr(dentry, iint);
162 struct dentry *dentry = file->f_dentry;
173 ima_fix_xattr(dentry, iint);
189 int must_appraise,
rc;
192 || !inode->
i_op->removexattr)
213 static int ima_protect_xattr(
struct dentry *dentry,
const char *xattr_name,
214 const void *xattr_value,
size_t xattr_value_len)
224 static void ima_reset_appraise_flags(
struct inode *
inode)
240 const void *xattr_value,
size_t xattr_value_len)
244 result = ima_protect_xattr(dentry, xattr_name, xattr_value,
247 ima_reset_appraise_flags(dentry->
d_inode);
257 result = ima_protect_xattr(dentry, xattr_name,
NULL, 0);
259 ima_reset_appraise_flags(dentry->
d_inode);