Skip to content

Commit fe0d34d

Browse files
committed
module: weaken locking assertion for oops path.
We don't actually hold the module_mutex when calling find_module_all from module_kallsyms_lookup_name: that's because it's used by the oops code and we don't want to deadlock. However, access to the list read-only is safe if preempt is disabled, so we can weaken the assertion. Keep a strong version for external callers though. Fixes: 0be964b ("module: Sanitize RCU usage and locking") Reported-by: He Kuang <[email protected]> Cc: [email protected] Acked-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Rusty Russell <[email protected]>
1 parent d61be4b commit fe0d34d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kernel/module.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -602,13 +602,16 @@ const struct kernel_symbol *find_symbol(const char *name,
602602
}
603603
EXPORT_SYMBOL_GPL(find_symbol);
604604

605-
/* Search for module by name: must hold module_mutex. */
605+
/*
606+
* Search for module by name: must hold module_mutex (or preempt disabled
607+
* for read-only access).
608+
*/
606609
static struct module *find_module_all(const char *name, size_t len,
607610
bool even_unformed)
608611
{
609612
struct module *mod;
610613

611-
module_assert_mutex();
614+
module_assert_mutex_or_preempt();
612615

613616
list_for_each_entry(mod, &modules, list) {
614617
if (!even_unformed && mod->state == MODULE_STATE_UNFORMED)
@@ -621,6 +624,7 @@ static struct module *find_module_all(const char *name, size_t len,
621624

622625
struct module *find_module(const char *name)
623626
{
627+
module_assert_mutex();
624628
return find_module_all(name, strlen(name), false);
625629
}
626630
EXPORT_SYMBOL_GPL(find_module);

0 commit comments

Comments
 (0)