[PATCH] module: Fix load_module() error path

From: Peter Zijlstra
Date: Wed Jul 08 2015 - 08:41:39 EST


On Wed, Jul 08, 2015 at 02:32:44PM +0200, Peter Zijlstra wrote:

> Awesome, lemme go write up a proper patch to make Rusty happy too ;-)

---
Subject: module: Fix load_module() error path
From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Date: Wed Jul 8 14:35:58 CEST 2015

The load_module() error path frees a module but forgot to take it out
of the mod_tree, leaving a dangling entry in the tree, causing havoc.

Cc: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
Reported-by: Arthur Marsh <arthur.marsh@xxxxxxxxxxxxxxxx>
Tested-by: Arthur Marsh <arthur.marsh@xxxxxxxxxxxxxxxx>
Fixes: 93c2e105f6bc ("module: Optimize __module_address() using a latched RB-tree")
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
kernel/module.c | 1 +
1 file changed, 1 insertion(+)

--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3557,6 +3557,7 @@ static int load_module(struct load_info
mutex_lock(&module_mutex);
/* Unlink carefully: kallsyms could be walking list. */
list_del_rcu(&mod->list);
+ mod_tree_remove(mod);
wake_up_all(&module_wq);
/* Wait for RCU-sched synchronizing before releasing mod->list. */
synchronize_sched();
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/