e5167230e5feacde340f051af5342d6d7bddeafd
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.2 / 0123-kprobes-initialize-before-using-a-hlist.patch
1 From 7e71cd56cf6675bb6ffebddbc6fae6cc1bc17d4d Mon Sep 17 00:00:00 2001
2 From: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
3 Date: Fri, 20 Jan 2012 14:34:04 -0800
4 Subject: [PATCH 123/130] kprobes: initialize before using a hlist
6 commit d496aab567e7e52b3e974c9192a5de6e77dce32c upstream.
8 Commit ef53d9c5e ("kprobes: improve kretprobe scalability with hashed
9 locking") introduced a bug where we can potentially leak
10 kretprobe_instances since we initialize a hlist head after having used
11 it.
13 Initialize the hlist head before using it.
15 Reported by: Jim Keniston <jkenisto@us.ibm.com>
16 Acked-by: Jim Keniston <jkenisto@us.ibm.com>
17 Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
18 Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
19 Cc: Srinivasa D S <srinivasa@in.ibm.com>
20 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
21 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
23 ---
24 kernel/kprobes.c | 2 +-
25 1 file changed, 1 insertion(+), 1 deletion(-)
27 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
28 index e5d8464..52fd049 100644
29 --- a/kernel/kprobes.c
30 +++ b/kernel/kprobes.c
31 @@ -1077,6 +1077,7 @@ void __kprobes kprobe_flush_task(struct task_struct *tk)
32 /* Early boot. kretprobe_table_locks not yet initialized. */
33 return;
35 + INIT_HLIST_HEAD(&empty_rp);
36 hash = hash_ptr(tk, KPROBE_HASH_BITS);
37 head = &kretprobe_inst_table[hash];
38 kretprobe_table_lock(hash, &flags);
39 @@ -1085,7 +1086,6 @@ void __kprobes kprobe_flush_task(struct task_struct *tk)
40 recycle_rp_inst(ri, &empty_rp);
41 }
42 kretprobe_table_unlock(hash, &flags);
43 - INIT_HLIST_HEAD(&empty_rp);
44 hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
45 hlist_del(&ri->hlist);
46 kfree(ri);
47 --
48 1.7.9.4