ima_main.c (6288cf1e768ae73db5ddaaae54d85245cc1c2b56) ima_main.c (f381c272224f5f158f5cff64f8f3481fa0eee8b3)
1/*
2 * Copyright (C) 2005,2006,2007,2008 IBM Corporation
3 *
4 * Authors:
5 * Reiner Sailer <sailer@watson.ibm.com>
6 * Serge Hallyn <serue@us.ibm.com>
7 * Kylene Hall <kylene@us.ibm.com>
8 * Mimi Zohar <zohar@us.ibm.com>

--- 68 unchanged lines hidden (view full) ---

77 if (send_tomtou)
78 ima_add_violation(inode, dentry->d_name.name, "invalid_pcr",
79 "ToMToU");
80 if (send_writers)
81 ima_add_violation(inode, dentry->d_name.name, "invalid_pcr",
82 "open_writers");
83}
84
1/*
2 * Copyright (C) 2005,2006,2007,2008 IBM Corporation
3 *
4 * Authors:
5 * Reiner Sailer <sailer@watson.ibm.com>
6 * Serge Hallyn <serue@us.ibm.com>
7 * Kylene Hall <kylene@us.ibm.com>
8 * Mimi Zohar <zohar@us.ibm.com>

--- 68 unchanged lines hidden (view full) ---

77 if (send_tomtou)
78 ima_add_violation(inode, dentry->d_name.name, "invalid_pcr",
79 "ToMToU");
80 if (send_writers)
81 ima_add_violation(inode, dentry->d_name.name, "invalid_pcr",
82 "open_writers");
83}
84
85static void ima_check_last_writer(struct ima_iint_cache *iint,
85static void ima_check_last_writer(struct integrity_iint_cache *iint,
86 struct inode *inode,
87 struct file *file)
88{
89 mode_t mode = file->f_mode;
90
91 mutex_lock(&iint->mutex);
92 if (mode & FMODE_WRITE &&
93 atomic_read(&inode->i_writecount) == 1 &&

--- 6 unchanged lines hidden (view full) ---

100 * ima_file_free - called on __fput()
101 * @file: pointer to file structure being freed
102 *
103 * Flag files that changed, based on i_version
104 */
105void ima_file_free(struct file *file)
106{
107 struct inode *inode = file->f_dentry->d_inode;
86 struct inode *inode,
87 struct file *file)
88{
89 mode_t mode = file->f_mode;
90
91 mutex_lock(&iint->mutex);
92 if (mode & FMODE_WRITE &&
93 atomic_read(&inode->i_writecount) == 1 &&

--- 6 unchanged lines hidden (view full) ---

100 * ima_file_free - called on __fput()
101 * @file: pointer to file structure being freed
102 *
103 * Flag files that changed, based on i_version
104 */
105void ima_file_free(struct file *file)
106{
107 struct inode *inode = file->f_dentry->d_inode;
108 struct ima_iint_cache *iint;
108 struct integrity_iint_cache *iint;
109
110 if (!iint_initialized || !S_ISREG(inode->i_mode))
111 return;
112
109
110 if (!iint_initialized || !S_ISREG(inode->i_mode))
111 return;
112
113 iint = ima_iint_find(inode);
113 iint = integrity_iint_find(inode);
114 if (!iint)
115 return;
116
117 ima_check_last_writer(iint, inode, file);
118}
119
120static int process_measurement(struct file *file, const unsigned char *filename,
121 int mask, int function)
122{
123 struct inode *inode = file->f_dentry->d_inode;
114 if (!iint)
115 return;
116
117 ima_check_last_writer(iint, inode, file);
118}
119
120static int process_measurement(struct file *file, const unsigned char *filename,
121 int mask, int function)
122{
123 struct inode *inode = file->f_dentry->d_inode;
124 struct ima_iint_cache *iint;
124 struct integrity_iint_cache *iint;
125 int rc = 0;
126
127 if (!ima_initialized || !S_ISREG(inode->i_mode))
128 return 0;
129
130 rc = ima_must_measure(inode, mask, function);
131 if (rc != 0)
132 return rc;
133retry:
125 int rc = 0;
126
127 if (!ima_initialized || !S_ISREG(inode->i_mode))
128 return 0;
129
130 rc = ima_must_measure(inode, mask, function);
131 if (rc != 0)
132 return rc;
133retry:
134 iint = ima_iint_find(inode);
134 iint = integrity_iint_find(inode);
135 if (!iint) {
135 if (!iint) {
136 rc = ima_inode_alloc(inode);
136 rc = integrity_inode_alloc(inode);
137 if (!rc || rc == -EEXIST)
138 goto retry;
139 return rc;
140 }
141
142 mutex_lock(&iint->mutex);
143
144 rc = iint->flags & IMA_MEASURED ? 1 : 0;

--- 96 unchanged lines hidden ---
137 if (!rc || rc == -EEXIST)
138 goto retry;
139 return rc;
140 }
141
142 mutex_lock(&iint->mutex);
143
144 rc = iint->flags & IMA_MEASURED ? 1 : 0;

--- 96 unchanged lines hidden ---