module: use RCU to synchronize find_module
[ Upstream commit a006050575745ca2be25118b90f1c37f454ac542 ] Allow for a RCU-sched critical section around find_module, following the lower level find_module_all helper, and switch the two callers outside of module.c to use such a RCU-sched critical section instead of module_mutex. Reviewed-by: Petr Mladek <pmladek@suse.com> Acked-by: Miroslav Benes <mbenes@suse.cz> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jessica Yu <jeyu@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
32edffff86
commit
bef9d8b4f8
@@ -19,6 +19,7 @@
|
||||
#include <linux/moduleloader.h>
|
||||
#include <linux/completion.h>
|
||||
#include <linux/memory.h>
|
||||
#include <linux/rcupdate.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include "core.h"
|
||||
#include "patch.h"
|
||||
@@ -57,7 +58,7 @@ static void klp_find_object_module(struct klp_object *obj)
|
||||
if (!klp_is_module(obj))
|
||||
return;
|
||||
|
||||
mutex_lock(&module_mutex);
|
||||
rcu_read_lock_sched();
|
||||
/*
|
||||
* We do not want to block removal of patched modules and therefore
|
||||
* we do not take a reference here. The patches are removed by
|
||||
@@ -74,7 +75,7 @@ static void klp_find_object_module(struct klp_object *obj)
|
||||
if (mod && mod->klp_alive)
|
||||
obj->mod = mod;
|
||||
|
||||
mutex_unlock(&module_mutex);
|
||||
rcu_read_unlock_sched();
|
||||
}
|
||||
|
||||
static bool klp_initialized(void)
|
||||
|
Reference in New Issue
Block a user