aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2015-02-28 16:24:48 -0500
committerJiri Kosina <jkosina@suse.cz>2015-03-02 18:22:55 -0500
commitc064a0de1bfb07c34a3798822c7e1636eea866e8 (patch)
treed91896f9a004e5e36809262a85791d6aec85a89e /kernel
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. [jkosina@suse.cz: change subject line to be aligned with other patches] Cc: Seth Jennings <sjenning@redhat.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Miroslav Benes <mbenes@suse.cz> Cc: Petr Mladek <pmladek@suse.cz> Cc: Jiri Kosina <jkosina@suse.cz> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/livepatch/core.c3
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,
248 /* first, check if it's an exported symbol */ 248 /* first, check if it's an exported symbol */
249 preempt_disable(); 249 preempt_disable();
250 sym = find_symbol(name, NULL, NULL, true, true); 250 sym = find_symbol(name, NULL, NULL, true, true);
251 preempt_enable();
252 if (sym) { 251 if (sym) {
253 *addr = sym->value; 252 *addr = sym->value;
253 preempt_enable();
254 return 0; 254 return 0;
255 } 255 }
256 preempt_enable();
256 257
257 /* otherwise check if it's in another .o within the patch module */ 258 /* otherwise check if it's in another .o within the patch module */
258 return klp_find_object_symbol(pmod->name, name, addr); 259 return klp_find_object_symbol(pmod->name, name, addr);