]> git.baikalelectronics.ru Git - kernel.git/commit
param: fix charp parameters set via sysfs
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 31 Mar 2009 19:05:29 +0000 (13:05 -0600)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 31 Mar 2009 02:35:30 +0000 (13:05 +1030)
commit93c0ebcd77457afd6139150b10f5b65f34cb57e6
treed52b950935f3192d13bdd4ad9377b39bab21325e
parentd32a706ea6880c2699d33f2f8c07b58abedb050f
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>
include/linux/module.h
include/linux/moduleparam.h
kernel/module.c
kernel/params.c