diff options
author | Peter Zijlstra <peterz@infradead.org> | 2015-05-26 21:39:35 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2015-05-26 21:39:50 -0400 |
commit | bed831f9a251968272dae10a83b512c7db256ef0 (patch) | |
tree | 8d567d72b09875aa162264ffddb353a2ac8b23cf /kernel/jump_label.c | |
parent | 926a59b1dfe2580e1a00bb2ba1664e5472077cbd (diff) |
module, jump_label: Fix module locking
As per the module core lockdep annotations in the coming patch:
[ 18.034047] ---[ end trace 9294429076a9c673 ]---
[ 18.047760] Hardware name: Intel Corporation S2600GZ/S2600GZ, BIOS SE5C600.86B.02.02.0002.122320131210 12/23/2013
[ 18.059228] ffffffff817d8676 ffff880036683c38 ffffffff8157e98b 0000000000000001
[ 18.067541] 0000000000000000 ffff880036683c78 ffffffff8105fbc7 ffff880036683c68
[ 18.075851] ffffffffa0046b08 0000000000000000 ffffffffa0046d00 ffffffffa0046cc8
[ 18.084173] Call Trace:
[ 18.086906] [<ffffffff8157e98b>] dump_stack+0x4f/0x7b
[ 18.092649] [<ffffffff8105fbc7>] warn_slowpath_common+0x97/0xe0
[ 18.099361] [<ffffffff8105fc2a>] warn_slowpath_null+0x1a/0x20
[ 18.105880] [<ffffffff810ee502>] __module_address+0x1d2/0x1e0
[ 18.112400] [<ffffffff81161153>] jump_label_module_notify+0x143/0x1e0
[ 18.119710] [<ffffffff810814bf>] notifier_call_chain+0x4f/0x70
[ 18.126326] [<ffffffff8108160e>] __blocking_notifier_call_chain+0x5e/0x90
[ 18.134009] [<ffffffff81081656>] blocking_notifier_call_chain+0x16/0x20
[ 18.141490] [<ffffffff810f0f00>] load_module+0x1b50/0x2660
[ 18.147720] [<ffffffff810f1ade>] SyS_init_module+0xce/0x100
[ 18.154045] [<ffffffff81587429>] system_call_fastpath+0x12/0x17
[ 18.160748] ---[ end trace 9294429076a9c674 ]---
Jump labels is not doing it right; fix this.
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jason Baron <jbaron@akamai.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel/jump_label.c')
-rw-r--r-- | kernel/jump_label.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/jump_label.c b/kernel/jump_label.c index 9019f15deab2..52ebaca1b9fc 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c | |||
@@ -302,7 +302,7 @@ static int jump_label_add_module(struct module *mod) | |||
302 | continue; | 302 | continue; |
303 | 303 | ||
304 | key = iterk; | 304 | key = iterk; |
305 | if (__module_address(iter->key) == mod) { | 305 | if (within_module(iter->key, mod)) { |
306 | /* | 306 | /* |
307 | * Set key->entries to iter, but preserve JUMP_LABEL_TRUE_BRANCH. | 307 | * Set key->entries to iter, but preserve JUMP_LABEL_TRUE_BRANCH. |
308 | */ | 308 | */ |
@@ -339,7 +339,7 @@ static void jump_label_del_module(struct module *mod) | |||
339 | 339 | ||
340 | key = (struct static_key *)(unsigned long)iter->key; | 340 | key = (struct static_key *)(unsigned long)iter->key; |
341 | 341 | ||
342 | if (__module_address(iter->key) == mod) | 342 | if (within_module(iter->key, mod)) |
343 | continue; | 343 | continue; |
344 | 344 | ||
345 | prev = &key->next; | 345 | prev = &key->next; |
@@ -443,14 +443,16 @@ static void jump_label_update(struct static_key *key, int enable) | |||
443 | { | 443 | { |
444 | struct jump_entry *stop = __stop___jump_table; | 444 | struct jump_entry *stop = __stop___jump_table; |
445 | struct jump_entry *entry = jump_label_get_entries(key); | 445 | struct jump_entry *entry = jump_label_get_entries(key); |
446 | |||
447 | #ifdef CONFIG_MODULES | 446 | #ifdef CONFIG_MODULES |
448 | struct module *mod = __module_address((unsigned long)key); | 447 | struct module *mod; |
449 | 448 | ||
450 | __jump_label_mod_update(key, enable); | 449 | __jump_label_mod_update(key, enable); |
451 | 450 | ||
451 | preempt_disable(); | ||
452 | mod = __module_address((unsigned long)key); | ||
452 | if (mod) | 453 | if (mod) |
453 | stop = mod->jump_entries + mod->num_jump_entries; | 454 | stop = mod->jump_entries + mod->num_jump_entries; |
455 | preempt_enable(); | ||
454 | #endif | 456 | #endif |
455 | /* if there are no users, entry can be NULL */ | 457 | /* if there are no users, entry can be NULL */ |
456 | if (entry) | 458 | if (entry) |