path: root/kernel/livepatch/core.c
diff options
authorPeter Zijlstra <>2015-02-28 22:24:48 +0100
committerJiri Kosina <>2015-03-03 00:22:55 +0100
commitc064a0de1bfb07c34a3798822c7e1636eea866e8 (patch)
treed91896f9a004e5e36809262a85791d6aec85a89e /kernel/livepatch/core.c
parentc4ce0da8ec62d83c96e29db7dadd6d3985344bb3 (diff)
livepatch: fix RCU usage in klp_find_external_symbol()
While one must hold RCU-sched (aka. preempt_disable) for find_symbol() one must equally hold it over the use of the object returned. The moment you release the RCU-sched read lock, the object can be dead and gone. [ change subject line to be aligned with other patches] Cc: Seth Jennings <> Cc: Josh Poimboeuf <> Cc: Masami Hiramatsu <> Cc: Miroslav Benes <> Cc: Petr Mladek <> Cc: Jiri Kosina <> Cc: "Paul E. McKenney" <> Cc: Rusty Russell <> Signed-off-by: Peter Zijlstra (Intel) <> Reviewed-by: Masami Hiramatsu <> Acked-by: Paul E. McKenney <> Acked-by: Josh Poimboeuf <> Signed-off-by: Jiri Kosina <>
Diffstat (limited to 'kernel/livepatch/core.c')
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 782172f073c5..01ca08804f51 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -248,11 +248,12 @@ static int klp_find_external_symbol(struct module *pmod, const char *name,
/* first, check if it's an exported symbol */
sym = find_symbol(name, NULL, NULL, true, true);
- preempt_enable();
if (sym) {
*addr = sym->value;
+ preempt_enable();
return 0;
+ preempt_enable();
/* otherwise check if it's in another .o within the patch module */
return klp_find_object_symbol(pmod->name, name, addr);