diff options
author | Xiaotian Feng <dfeng@redhat.com> | 2010-02-08 16:22:24 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2010-02-08 16:22:24 -0500 |
commit | 8007f10259d04f37044c2c731bf9ccdd9161d825 (patch) | |
tree | 6accff6b70b4780bc62824c419582f4cace56f23 /security | |
parent | ea13ddbad0eb4be9cdc406cd7e0804fa4011f6e4 (diff) |
selinux: fix memory leak in sel_make_bools
In sel_make_bools, kernel allocates memory for bool_pending_names[i]
with security_get_bools. So if we just free bool_pending_names, those
memories for bool_pending_names[i] will be leaked.
This patch resolves dozens of following kmemleak report after resuming
from suspend:
unreferenced object 0xffff88022e4c7380 (size 32):
comm "init", pid 1, jiffies 4294677173
backtrace:
[<ffffffff810f76b5>] create_object+0x1a2/0x2a9
[<ffffffff810f78bb>] kmemleak_alloc+0x26/0x4b
[<ffffffff810ef3eb>] __kmalloc+0x18f/0x1b8
[<ffffffff811cd511>] security_get_bools+0xd7/0x16f
[<ffffffff811c48c0>] sel_write_load+0x12e/0x62b
[<ffffffff810f9a39>] vfs_write+0xae/0x10b
[<ffffffff810f9b56>] sys_write+0x4a/0x6e
[<ffffffff81011b82>] system_call_fastpath+0x16/0x1b
[<ffffffffffffffff>] 0xffffffffffffffff
Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security')
-rw-r--r-- | security/selinux/selinuxfs.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index a1cfc464bbb9..cd191bbec03c 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c | |||
@@ -977,6 +977,8 @@ static int sel_make_bools(void) | |||
977 | u32 sid; | 977 | u32 sid; |
978 | 978 | ||
979 | /* remove any existing files */ | 979 | /* remove any existing files */ |
980 | for (i = 0; i < bool_num; i++) | ||
981 | kfree(bool_pending_names[i]); | ||
980 | kfree(bool_pending_names); | 982 | kfree(bool_pending_names); |
981 | kfree(bool_pending_values); | 983 | kfree(bool_pending_values); |
982 | bool_pending_names = NULL; | 984 | bool_pending_names = NULL; |