aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rcu
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 /kernel/rcu
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 'kernel/rcu')
-rw-r--r--kernel/rcu/update.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
index a9df198eb22d..3e888cd5a594 100644
--- a/kernel/rcu/update.c
+++ b/kernel/rcu/update.c
@@ -380,29 +380,9 @@ void destroy_rcu_head(struct rcu_head *head)
380 debug_object_free(head, &rcuhead_debug_descr); 380 debug_object_free(head, &rcuhead_debug_descr);
381} 381}
382 382
383/* 383static bool rcuhead_is_static_object(void *addr)
384 * fixup_activate is called when:
385 * - an active object is activated
386 * - an unknown object is activated (might be a statically initialized object)
387 * Activation is performed internally by call_rcu().
388 */
389static bool rcuhead_fixup_activate(void *addr, enum debug_obj_state state)
390{ 384{
391 struct rcu_head *head = addr; 385 return true;
392
393 switch (state) {
394
395 case ODEBUG_STATE_NOTAVAILABLE:
396 /*
397 * This is not really a fixup. We just make sure that it is
398 * tracked in the object tracker.
399 */
400 debug_object_init(head, &rcuhead_debug_descr);
401 debug_object_activate(head, &rcuhead_debug_descr);
402 return false;
403 default:
404 return true;
405 }
406} 386}
407 387
408/** 388/**
@@ -440,7 +420,7 @@ EXPORT_SYMBOL_GPL(destroy_rcu_head_on_stack);
440 420
441struct debug_obj_descr rcuhead_debug_descr = { 421struct debug_obj_descr rcuhead_debug_descr = {
442 .name = "rcu_head", 422 .name = "rcu_head",
443 .fixup_activate = rcuhead_fixup_activate, 423 .is_static_object = rcuhead_is_static_object,
444}; 424};
445EXPORT_SYMBOL_GPL(rcuhead_debug_descr); 425EXPORT_SYMBOL_GPL(rcuhead_debug_descr);
446#endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */ 426#endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */