OSDN Git Service

ima: use path names cache
authorDmitry Kasatkin <dmitry.kasatkin@gmail.com>
Wed, 1 Oct 2014 18:43:10 +0000 (21:43 +0300)
committerMimi Zohar <zohar@linux.vnet.ibm.com>
Tue, 7 Oct 2014 18:32:54 +0000 (14:32 -0400)
__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>
security/integrity/ima/ima_api.c
security/integrity/ima/ima_main.c

index 8688597..a99eb6d 100644 (file)
@@ -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;
                }
index 72faf0b..eeee00d 100644 (file)
@@ -246,7 +246,8 @@ out_digsig:
                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))