Skip to content

Commit

Permalink
ftrace: safe traversal of ftrace_hash hlist
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Abhishek Sagar authored and Thomas Gleixner committed May 26, 2008
1 parent ccbfac2 commit ffdaa35
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit ffdaa35

Please sign in to comment.