]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
EVM: fix memory leak of temporary buffer 'temp'
authorColin Ian King <colin.king@canonical.com>
Sun, 27 May 2018 22:15:02 +0000 (23:15 +0100)
committerMimi Zohar <zohar@linux.vnet.ibm.com>
Thu, 31 May 2018 14:13:22 +0000 (10:13 -0400)
The allocation of 'temp' is not kfree'd and hence there is a memory
leak on each call of evm_read_xattrs.  Fix this by kfree'ing it
after copying data from it back to the user space buffer 'buf'.

Detected by CoverityScan, CID#1469386 ("Resource Leak")

Fixes: fa516b66a1bf ("EVM: Allow runtime modification of the set of verified xattrs")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
security/integrity/evm/evm_secfs.c

index a7a0a1acae9960f77305ef3b869e603d8cd336fe..fb8bc950aceb44d234ee469e43c3ff674c90e535 100644 (file)
@@ -158,6 +158,8 @@ static ssize_t evm_read_xattrs(struct file *filp, char __user *buf,
        mutex_unlock(&xattr_list_mutex);
        rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
 
+       kfree(temp);
+
        return rc;
 }