]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ftrace: Using FTRACE_WARN_ON() to check "freed record" in ftrace_release()
authorZhaolei <zhaolei@cn.fujitsu.com>
Wed, 25 Mar 2009 04:06:05 +0000 (12:06 +0800)
committerSteven Rostedt <srostedt@redhat.com>
Wed, 25 Mar 2009 21:45:36 +0000 (17:45 -0400)
 "Because when we call ftrace_free_rec we change the rec->ip to point to the
  next record in the chain. Something is very wrong if rec->ip >= s &&
  rec->ip < e and the record is already free."

 "Note, use FTRACE_WARN_ON() macro. This way it shuts down ftrace if it is
  hit and helps to avoid further damage later."
                   -- Steven Rostedt <rostedt@goodmis.org>

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
kernel/trace/ftrace.c

index 7b8722baf1531b3f82df2dde923d343332bd7d6e..1752a63f37c02d535b961a68efa20313cb147faf 100644 (file)
@@ -358,9 +358,14 @@ void ftrace_release(void *start, unsigned long size)
 
        mutex_lock(&ftrace_lock);
        do_for_each_ftrace_rec(pg, rec) {
-               if ((rec->ip >= s) && (rec->ip < e) &&
-                   !(rec->flags & FTRACE_FL_FREE))
+               if ((rec->ip >= s) && (rec->ip < e)) {
+                       /*
+                        * rec->ip is changed in ftrace_free_rec()
+                        * It should not between s and e if record was freed.
+                        */
+                       FTRACE_WARN_ON(rec->flags & FTRACE_FL_FREE);
                        ftrace_free_rec(rec);
+               }
        } while_for_each_ftrace_rec();
        mutex_unlock(&ftrace_lock);
 }