Skip to content

Commit 456f5fd

Browse files
kdsossMimi Zohar
authored andcommitted
ima: use path names cache
__getname() uses slab allocation which is faster than kmalloc. Make use of it. Signed-off-by: Dmitry Kasatkin <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent c2baec7 commit 456f5fd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

security/integrity/ima/ima_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ const char *ima_d_path(struct path *path, char **pathbuf)
325325
{
326326
char *pathname = NULL;
327327

328-
*pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
328+
*pathbuf = __getname();
329329
if (*pathbuf) {
330330
pathname = d_absolute_path(path, *pathbuf, PATH_MAX);
331331
if (IS_ERR(pathname)) {
332-
kfree(*pathbuf);
332+
__putname(*pathbuf);
333333
*pathbuf = NULL;
334334
pathname = NULL;
335335
}

security/integrity/ima/ima_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ static int process_measurement(struct file *file, int mask, int function,
246246
rc = -EACCES;
247247
kfree(xattr_value);
248248
out_free:
249-
kfree(pathbuf);
249+
if (pathbuf)
250+
__putname(pathbuf);
250251
out:
251252
mutex_unlock(&inode->i_mutex);
252253
if ((rc && must_appraise) && (ima_appraise & IMA_APPRAISE_ENFORCE))

0 commit comments

Comments
 (0)