Commit 825e6a0f authored by Eric Richter's avatar Eric Richter Committed by Greg Kroah-Hartman

ima: fix memory leak in ima_release_policy

commit 9a11a189 upstream.

When the "policy" securityfs file is opened for read, it is opened as a
sequential file. However, when it is eventually released, there is no
cleanup for the sequential file, therefore some memory is leaked.

This patch adds a call to seq_release() in ima_release_policy() to clean up
the memory when the file is opened for read.

Fixes: 80eae209 IMA: allow reading back the current policy
Reported-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarEric Richter <erichte@linux.vnet.ibm.com>
Tested-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarMimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c4c11b4b
......@@ -401,7 +401,7 @@ static int ima_release_policy(struct inode *inode, struct file *file)
const char *cause = valid_policy ? "completed" : "failed";
if ((file->f_flags & O_ACCMODE) == O_RDONLY)
return 0;
return seq_release(inode, file);
if (valid_policy && ima_check_policy() < 0) {
cause = "failed";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment