Skip to content

Commit

Permalink
livepatch: fix RCU usage in klp_find_external_symbol()
Browse files Browse the repository at this point in the history
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.

[[email protected]: change subject line to be aligned with other patches]
Cc: Seth Jennings <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Miroslav Benes <[email protected]>
Cc: Petr Mladek <[email protected]>
Cc: Jiri Kosina <[email protected]>
Cc: "Paul E. McKenney" <[email protected]>
Cc: Rusty Russell <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Masami Hiramatsu <[email protected]>
Acked-by: Paul E. McKenney <[email protected]>
Acked-by: Josh Poimboeuf <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
  • Loading branch information
Peter Zijlstra authored and Jiri Kosina committed Mar 2, 2015
1 parent c4ce0da commit c064a0d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/livepatch/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,12 @@ static int klp_find_external_symbol(struct module *pmod, const char *name,
/* first, check if it's an exported symbol */
preempt_disable();
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);
Expand Down

0 comments on commit c064a0d

Please sign in to comment.