17 #include <linux/module.h>
19 #include <linux/xattr.h>
31 #ifdef CONFIG_SECURITY_SELINUX
34 #ifdef CONFIG_SECURITY_SMACK
37 #ifdef CONFIG_IMA_APPRAISE
44 static int evm_fixmode;
45 static int __init evm_set_fixmode(
char *
str)
47 if (
strncmp(str,
"fix", 3) == 0)
51 __setup(
"evm=", evm_set_fixmode);
53 static int evm_find_protected_xattrs(
struct dentry *
dentry)
60 if (!inode->
i_op || !inode->
i_op->getxattr)
64 error = inode->
i_op->getxattr(dentry, *xattr,
NULL, 0);
90 const char *xattr_name,
92 size_t xattr_value_len,
112 rc = evm_find_protected_xattrs(dentry);
124 switch (xattr_data->
type) {
127 xattr_value_len, calc.digest);
131 sizeof(calc.digest));
137 xattr_value_len, calc.digest);
141 xattr_data->
digest, xattr_len,
142 calc.digest,
sizeof(calc.digest));
155 evm_status = (rc == -
ENODATA) ?
164 static int evm_protected_xattr(
const char *req_xattr_name)
170 namelen =
strlen(req_xattr_name);
172 if ((
strlen(*xattrname) == namelen)
173 && (
strncmp(req_xattr_name, *xattrname, namelen) == 0)) {
179 strlen(req_xattr_name)) == 0) {
204 const char *xattr_name,
205 void *xattr_value,
size_t xattr_value_len,
216 return evm_verify_hmac(dentry, xattr_name, xattr_value,
217 xattr_value_len, iint);
228 static enum integrity_status evm_verify_current_integrity(
struct dentry *dentry)
230 struct inode *inode = dentry->
d_inode;
249 static int evm_protect_xattr(
struct dentry *dentry,
const char *xattr_name,
250 const void *xattr_value,
size_t xattr_value_len)
257 }
else if (!evm_protected_xattr(xattr_name)) {
260 evm_status = evm_verify_current_integrity(dentry);
266 evm_status = evm_verify_current_integrity(dentry);
281 const void *xattr_value,
size_t xattr_value_len)
283 return evm_protect_xattr(dentry, xattr_name, xattr_value,
297 return evm_protect_xattr(dentry, xattr_name,
NULL, 0);
314 const void *xattr_value,
size_t xattr_value_len)
333 struct inode *inode = dentry->
d_inode;
350 unsigned int ia_valid = attr->
ia_valid;
355 evm_status = evm_verify_current_integrity(dentry);
387 const struct xattr *lsm_xattr,
388 struct xattr *evm_xattr)
396 xattr_data = kzalloc(
sizeof(*xattr_data),
GFP_NOFS);
405 evm_xattr->
value = xattr_data;
406 evm_xattr->
value_len =
sizeof(*xattr_data);
415 static int __init init_evm(
void)
430 static void __exit cleanup_evm(
void)
442 static int __init evm_display_config(
void)