19 #include <linux/module.h>
21 #include <linux/binfmts.h>
23 #include <linux/mman.h>
24 #include <linux/slab.h>
25 #include <linux/xattr.h>
32 #ifdef CONFIG_IMA_APPRAISE
41 if (
strncmp(str,
"md5", 3) == 0)
45 __setup(
"ima_hash=", hash_setup);
57 static void ima_rdwr_violation_check(
struct file *
file)
63 bool send_tomtou =
false, send_writers =
false;
86 if (!send_tomtou && !send_writers)
100 !pathname ? dentry->
d_name.name : pathname,
101 "invalid_pcr",
"ToMToU");
104 !pathname ? dentry->
d_name.name : pathname,
105 "invalid_pcr",
"open_writers");
110 struct inode *inode,
struct file *file)
114 if (!(mode & FMODE_WRITE))
135 struct inode *inode = file->f_dentry->d_inode;
145 ima_check_last_writer(iint, inode, file);
148 static int process_measurement(
struct file *file,
const unsigned char *
filename,
149 int mask,
int function)
151 struct inode *inode = file->f_dentry->d_inode;
153 unsigned char *pathname =
NULL, *pathbuf =
NULL;
196 if (IS_ERR(pathname))
202 !pathname ? filename : pathname);
203 if (action & IMA_APPRAISE)
205 !pathname ? filename : pathname);
211 return (rc && must_appraise) ? -
EACCES : 0;
232 rc = process_measurement(file, file->f_dentry->d_name.
name,
254 rc = process_measurement(bprm->
file,
275 ima_rdwr_violation_check(file);
276 rc = process_measurement(file, file->f_dentry->d_name.
name,
283 static int __init init_ima(
void)