diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-03-31 15:05:29 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-03-30 22:35:30 -0400 |
commit | e180a6b7759a99a28cbcce3547c4c80822cb6c2a (patch) | |
tree | d52b950935f3192d13bdd4ad9377b39bab21325e /include/linux/moduleparam.h | |
parent | 15f7176eb1cccec0a332541285ee752b935c1c85 (diff) |
param: fix charp parameters set via sysfs
Impact: fix crash on reading from /sys/module/.../ieee80211_default_rc_algo
The module_param type "charp" simply sets a char * pointer in the
module to the parameter in the commandline string: this is why we keep
the (mangled) module command line around. But when set via sysfs (as
about 11 charp parameters can be) this memory is freed on the way
out of the write(). Future reads hit random mem.
So we kstrdup instead: we have to check we're not in early commandline
parsing, and we have to note when we've used it so we can reliably
kfree the parameter when it's next overwritten, and also on module
unload.
(Thanks to Randy Dunlap for CONFIG_SYSFS=n fixes)
Reported-by: Sitsofe Wheeler <sitsofe@yahoo.com>
Diagnosed-by: Frederic Weisbecker <fweisbec@gmail.com>
Tested-by: Frederic Weisbecker <fweisbec@gmail.com>
Tested-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include/linux/moduleparam.h')
-rw-r--r-- | include/linux/moduleparam.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index e4af3399ef48..a4f0b931846c 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h | |||
@@ -138,6 +138,16 @@ extern int parse_args(const char *name, | |||
138 | unsigned num, | 138 | unsigned num, |
139 | int (*unknown)(char *param, char *val)); | 139 | int (*unknown)(char *param, char *val)); |
140 | 140 | ||
141 | /* Called by module remove. */ | ||
142 | #ifdef CONFIG_SYSFS | ||
143 | extern void destroy_params(const struct kernel_param *params, unsigned num); | ||
144 | #else | ||
145 | static inline void destroy_params(const struct kernel_param *params, | ||
146 | unsigned num) | ||
147 | { | ||
148 | } | ||
149 | #endif /* !CONFIG_SYSFS */ | ||
150 | |||
141 | /* All the helper functions */ | 151 | /* All the helper functions */ |
142 | /* The macros to do compile-time type checking stolen from Jakub | 152 | /* The macros to do compile-time type checking stolen from Jakub |
143 | Jelinek, who IIRC came up with this idea for the 2.4 module init code. */ | 153 | Jelinek, who IIRC came up with this idea for the 2.4 module init code. */ |