aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Kasatkin <d.kasatkin@samsung.com>2013-11-13 15:23:20 -0500
committerMimi Zohar <zohar@linux.vnet.ibm.com>2014-03-07 12:15:46 -0500
commit61997c4383c28fe93fb053295562ff6482ef5c07 (patch)
tree4db0680a4246655d9176a46bc0b60d520da13a17
parent2bb930abcf39d8be243ddb4583cf013ea2a750d6 (diff)
ima: return d_name.name if d_path fails
This is a small refactoring so ima_d_path() returns dentry name if path reconstruction fails. It simplifies callers actions and removes code duplication. Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
-rw-r--r--security/integrity/ima/ima_api.c2
-rw-r--r--security/integrity/ima/ima_main.c7
2 files changed, 2 insertions, 7 deletions
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index c6b4a732e89b..ba9e4d792dd5 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -332,5 +332,5 @@ const char *ima_d_path(struct path *path, char **pathbuf)
332 pathname = NULL; 332 pathname = NULL;
333 } 333 }
334 } 334 }
335 return pathname; 335 return pathname ?: (const char *)path->dentry->d_name.name;
336} 336}
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 50413d02ac3a..52ac6cf41f88 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -79,7 +79,6 @@ __setup("ima_hash=", hash_setup);
79 */ 79 */
80static void ima_rdwr_violation_check(struct file *file) 80static void ima_rdwr_violation_check(struct file *file)
81{ 81{
82 struct dentry *dentry = file->f_path.dentry;
83 struct inode *inode = file_inode(file); 82 struct inode *inode = file_inode(file);
84 fmode_t mode = file->f_mode; 83 fmode_t mode = file->f_mode;
85 int must_measure; 84 int must_measure;
@@ -111,8 +110,6 @@ out:
111 return; 110 return;
112 111
113 pathname = ima_d_path(&file->f_path, &pathbuf); 112 pathname = ima_d_path(&file->f_path, &pathbuf);
114 if (!pathname || strlen(pathname) > IMA_EVENT_NAME_LEN_MAX)
115 pathname = dentry->d_name.name;
116 113
117 if (send_tomtou) 114 if (send_tomtou)
118 ima_add_violation(file, pathname, "invalid_pcr", "ToMToU"); 115 ima_add_violation(file, pathname, "invalid_pcr", "ToMToU");
@@ -220,9 +217,7 @@ static int process_measurement(struct file *file, const char *filename,
220 if (rc != 0) 217 if (rc != 0)
221 goto out_digsig; 218 goto out_digsig;
222 219
223 pathname = !filename ? ima_d_path(&file->f_path, &pathbuf) : filename; 220 pathname = filename ?: ima_d_path(&file->f_path, &pathbuf);
224 if (!pathname)
225 pathname = (const char *)file->f_dentry->d_name.name;
226 221
227 if (action & IMA_MEASURE) 222 if (action & IMA_MEASURE)
228 ima_store_measurement(iint, file, pathname, 223 ima_store_measurement(iint, file, pathname,