aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/module.h
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@ieee.org>2015-06-17 06:18:52 +0930
committerRusty Russell <rusty@rustcorp.com.au>2015-06-23 15:27:38 +0930
commitb51d23e4e9fea6f264d39535c2a62d1f51e7ccc3 (patch)
tree032ebaa1088f1c20985b0872ab31a9d403a35884 /include/linux/module.h
parentmodule: make perm const (diff)
downloadlinux-dev-b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3.tar.xz
linux-dev-b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3.zip
module: add per-module param_lock
Add a "param_lock" mutex to each module, and update params.c to use the correct built-in or module mutex while locking kernel params. Remove the kparam_block_sysfs_r/w() macros, replace them with direct calls to kernel_param_[un]lock(module). The kernel param code currently uses a single mutex to protect modification of any and all kernel params. While this generally works, there is one specific problem with it; a module callback function cannot safely load another module, i.e. with request_module() or even with indirect calls such as crypto_has_alg(). If the module to be loaded has any of its params configured (e.g. with a /etc/modprobe.d/* config file), then the attempt will result in a deadlock between the first module param callback waiting for modprobe, and modprobe trying to lock the single kernel param mutex to set the new module's param. This fixes that by using per-module mutexes, so that each individual module is protected against concurrent changes in its own kernel params, but is not blocked by changes to other module params. All built-in modules continue to use the built-in mutex, since they will always be loaded at runtime and references (e.g. request_module(), crypto_has_alg()) to them will never cause load-time param changing. This also simplifies the interface used by modules to block sysfs access to their params; while there are currently functions to block and unblock sysfs param access which are split up by read and write and expect a single kernel param to be passed, their actual operation is identical and applies to all params, not just the one passed to them; they simply lock and unlock the global param mutex. They are replaced with direct calls to kernel_param_[un]lock(THIS_MODULE), which locks THIS_MODULE's param_lock, or if the module is built-in, it locks the built-in mutex. Suggested-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include/linux/module.h')
-rw-r--r--include/linux/module.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/module.h b/include/linux/module.h
index 4c1b02e1361d..6ba0e87fa804 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -240,6 +240,7 @@ struct module {
unsigned int num_syms;
/* Kernel parameters. */
+ struct mutex param_lock;
struct kernel_param *kp;
unsigned int num_kp;