aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/debugobjects.h
diff options
context:
space:
mode:
authorDu, Changbin <changbin.du@intel.com>2016-05-19 20:09:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-19 22:12:14 -0400
commitb9fdac7f660609abb157500e468d2165b3c9cf08 (patch)
tree37d3b704f52b46dfb6d9ebb24611870dbb2b93be /include/linux/debugobjects.h
parent8bad1cd0e1edd124c0f05f925762ef84e6047586 (diff)
debugobjects: insulate non-fixup logic related to static obj from fixup callbacks
When activating a static object we need make sure that the object is tracked in the object tracker. If it is a non-static object then the activation is illegal. In previous implementation, each subsystem need take care of this in their fixup callbacks. Actually we can put it into debugobjects core. Thus we can save duplicated code, and have *pure* fixup callbacks. To achieve this, a new callback "is_static_object" is introduced to let the type specific code decide whether a object is static or not. If yes, we take it into object tracker, otherwise give warning and invoke fixup callback. This change has paassed debugobjects selftest, and I also do some test with all debugobjects supports enabled. At last, I have a concern about the fixups that can it change the object which is in incorrect state on fixup? Because the 'addr' may not point to any valid object if a non-static object is not tracked. Then Change such object can overwrite someone's memory and cause unexpected behaviour. For example, the timer_fixup_activate bind timer to function stub_timer. Link: http://lkml.kernel.org/r/1462576157-14539-1-git-send-email-changbin.du@intel.com [changbin.du@intel.com: improve code comments where invoke the new is_static_object callback] Link: http://lkml.kernel.org/r/1462777431-8171-1-git-send-email-changbin.du@intel.com Signed-off-by: Du, Changbin <changbin.du@intel.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Josh Triplett <josh@kernel.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tejun Heo <tj@kernel.org> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/debugobjects.h')
-rw-r--r--include/linux/debugobjects.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/debugobjects.h b/include/linux/debugobjects.h
index a899f10c9365..46056cb161fc 100644
--- a/include/linux/debugobjects.h
+++ b/include/linux/debugobjects.h
@@ -38,6 +38,7 @@ struct debug_obj {
38 * @name: name of the object typee 38 * @name: name of the object typee
39 * @debug_hint: function returning address, which have associated 39 * @debug_hint: function returning address, which have associated
40 * kernel symbol, to allow identify the object 40 * kernel symbol, to allow identify the object
41 * @is_static_object return true if the obj is static, otherwise return false
41 * @fixup_init: fixup function, which is called when the init check 42 * @fixup_init: fixup function, which is called when the init check
42 * fails. All fixup functions must return true if fixup 43 * fails. All fixup functions must return true if fixup
43 * was successful, otherwise return false 44 * was successful, otherwise return false
@@ -53,6 +54,7 @@ struct debug_obj {
53struct debug_obj_descr { 54struct debug_obj_descr {
54 const char *name; 55 const char *name;
55 void *(*debug_hint)(void *addr); 56 void *(*debug_hint)(void *addr);
57 bool (*is_static_object)(void *addr);
56 bool (*fixup_init)(void *addr, enum debug_obj_state state); 58 bool (*fixup_init)(void *addr, enum debug_obj_state state);
57 bool (*fixup_activate)(void *addr, enum debug_obj_state state); 59 bool (*fixup_activate)(void *addr, enum debug_obj_state state);
58 bool (*fixup_destroy)(void *addr, enum debug_obj_state state); 60 bool (*fixup_destroy)(void *addr, enum debug_obj_state state);