aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/auditfilter.c
diff options
context:
space:
mode:
authorChen Gang <gang.chen@asianux.com>2013-04-29 18:05:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 18:54:26 -0400
commit373e0f3408fe671550d69d9a7965d8a49e988525 (patch)
tree4005a557ef08eda7542ba349d66695caacf54224 /kernel/auditfilter.c
parentdde5b7d6e7be308ce371baa96058c2d40df26c05 (diff)
kernel/auditfilter.c: tree and watch will memory leak when failure occurs
In audit_data_to_entry() when a failure occurs we must check and free the tree and watch to avoid a memory leak. test: plan: test command: "auditctl -a exit,always -w /etc -F auid=-1" (on fedora17, need modify auditctl to let "-w /etc" has effect) running: under fedora17 x86_64, 2 CPUs 3.20GHz, 2.5GB RAM. let 15 auditctl processes continue running at the same time. monitor command: watch -d -n 1 "cat /proc/meminfo | awk '{print \$2}' \ | head -n 4 | xargs \ | awk '{print \"used \",\$1 - \$2 - \$3 - \$4}'" result: for original version: will use up all memory, within 3 hours. kill all auditctl, the memory still does not free. for new version (apply this patch): after 14 hours later, not find issues. Signed-off-by: Chen Gang <gang.chen@asianux.com> Cc: Eric Paris <eparis@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/auditfilter.c')
-rw-r--r--kernel/auditfilter.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index f9fc54bbe06f..267436826c3b 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -594,6 +594,10 @@ exit_nofree:
594 return entry; 594 return entry;
595 595
596exit_free: 596exit_free:
597 if (entry->rule.watch)
598 audit_put_watch(entry->rule.watch); /* matches initial get */
599 if (entry->rule.tree)
600 audit_put_tree(entry->rule.tree); /* that's the temporary one */
597 audit_free_rule(entry); 601 audit_free_rule(entry);
598 return ERR_PTR(err); 602 return ERR_PTR(err);
599} 603}