]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ftrace: safe traversal of ftrace_hash hlist
authorAbhishek Sagar <sagar.abhishek@gmail.com>
Sat, 24 May 2008 18:15:02 +0000 (23:45 +0530)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 26 May 2008 20:52:04 +0000 (22:52 +0200)
Hi Steven,

I noticed that concurrent instances of ftrace_record_ip()
have a race between ftrace_hash list traversal during
ftrace_ip_in_hash() (before acquiring ftrace_shutdown_lock)
and ftrace_add_hash(). If it's so then this should fix it.

Signed-off-by: Abhishek Sagar <sagar.abhishek@gmail.com>
Cc: rostedt@goodmis.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/trace/ftrace.c

index 2552454609cfdba7e489ccde7038149c4b0c33bc..9b7c54f8a62f9ea50ddad347c86a9cfc8b642b22 100644 (file)
@@ -201,7 +201,7 @@ ftrace_ip_in_hash(unsigned long ip, unsigned long key)
        struct hlist_node *t;
        int found = 0;
 
-       hlist_for_each_entry(p, t, &ftrace_hash[key], node) {
+       hlist_for_each_entry_rcu(p, t, &ftrace_hash[key], node) {
                if (p->ip == ip) {
                        found = 1;
                        break;
@@ -214,7 +214,7 @@ ftrace_ip_in_hash(unsigned long ip, unsigned long key)
 static inline void
 ftrace_add_hash(struct dyn_ftrace *node, unsigned long key)
 {
-       hlist_add_head(&node->node, &ftrace_hash[key]);
+       hlist_add_head_rcu(&node->node, &ftrace_hash[key]);
 }
 
 static void ftrace_free_rec(struct dyn_ftrace *rec)