Skip to content

Commit

Permalink
ima: use path names cache
Browse files Browse the repository at this point in the history
__getname() uses slab allocation which is faster than kmalloc.
Make use of it.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
  • Loading branch information
Dmitry Kasatkin authored and Mimi Zohar committed Oct 7, 2014
1 parent c2baec7 commit 456f5fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions security/integrity/ima/ima_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,11 @@ const char *ima_d_path(struct path *path, char **pathbuf)
{
char *pathname = NULL;

*pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
*pathbuf = __getname();
if (*pathbuf) {
pathname = d_absolute_path(path, *pathbuf, PATH_MAX);
if (IS_ERR(pathname)) {
kfree(*pathbuf);
__putname(*pathbuf);
*pathbuf = NULL;
pathname = NULL;
}
Expand Down
3 changes: 2 additions & 1 deletion security/integrity/ima/ima_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ static int process_measurement(struct file *file, int mask, int function,
rc = -EACCES;
kfree(xattr_value);
out_free:
kfree(pathbuf);
if (pathbuf)
__putname(pathbuf);
out:
mutex_unlock(&inode->i_mutex);
if ((rc && must_appraise) && (ima_appraise & IMA_APPRAISE_ENFORCE))
Expand Down

0 comments on commit 456f5fd

Please sign in to comment.