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>
This commit is contained in:
Dmitry Kasatkin 2013-11-13 22:23:20 +02:00 committed by Mimi Zohar
parent 2bb930abcf
commit 61997c4383
2 changed files with 2 additions and 7 deletions

View file

@ -332,5 +332,5 @@ const char *ima_d_path(struct path *path, char **pathbuf)
pathname = NULL; pathname = NULL;
} }
} }
return pathname; return pathname ?: (const char *)path->dentry->d_name.name;
} }

View file

@ -79,7 +79,6 @@ __setup("ima_hash=", hash_setup);
*/ */
static void ima_rdwr_violation_check(struct file *file) static void ima_rdwr_violation_check(struct file *file)
{ {
struct dentry *dentry = file->f_path.dentry;
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
fmode_t mode = file->f_mode; fmode_t mode = file->f_mode;
int must_measure; int must_measure;
@ -111,8 +110,6 @@ out:
return; return;
pathname = ima_d_path(&file->f_path, &pathbuf); pathname = ima_d_path(&file->f_path, &pathbuf);
if (!pathname || strlen(pathname) > IMA_EVENT_NAME_LEN_MAX)
pathname = dentry->d_name.name;
if (send_tomtou) if (send_tomtou)
ima_add_violation(file, pathname, "invalid_pcr", "ToMToU"); ima_add_violation(file, pathname, "invalid_pcr", "ToMToU");
@ -220,9 +217,7 @@ static int process_measurement(struct file *file, const char *filename,
if (rc != 0) if (rc != 0)
goto out_digsig; goto out_digsig;
pathname = !filename ? ima_d_path(&file->f_path, &pathbuf) : filename; pathname = filename ?: ima_d_path(&file->f_path, &pathbuf);
if (!pathname)
pathname = (const char *)file->f_dentry->d_name.name;
if (action & IMA_MEASURE) if (action & IMA_MEASURE)
ima_store_measurement(iint, file, pathname, ima_store_measurement(iint, file, pathname,