summaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorChen Gang <gang.chen@asianux.com>2013-08-20 15:34:21 +0930
committerRusty Russell <rusty@rustcorp.com.au>2013-08-20 15:37:46 +0930
commitcc56ded3fdd365e07e03315379ee6612a68fd817 (patch)
tree0335af371e340556297fc4ac041f537e8ff2e5de /kernel/module.c
parent5265fc6219ddbf8dfc9b18223448a4997fb06eae (diff)
downloadop-kernel-dev-cc56ded3fdd365e07e03315379ee6612a68fd817.zip
op-kernel-dev-cc56ded3fdd365e07e03315379ee6612a68fd817.tar.gz
kernel/module.c: use scnprintf() instead of sprintf()
For some strings, they are permitted to be larger than PAGE_SIZE, so need use scnprintf() instead of sprintf(), or it will cause issue. One case is: if a module version is crazy defined (length more than PAGE_SIZE), 'modinfo' command is still OK (print full contents), but for "cat /sys/modules/'modname'/version", will cause issue in kernel. Signed-off-by: Chen Gang <gang.chen@asianux.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 4eb26b6..40ee1dc 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -604,7 +604,7 @@ static void setup_modinfo_##field(struct module *mod, const char *s) \
static ssize_t show_modinfo_##field(struct module_attribute *mattr, \
struct module_kobject *mk, char *buffer) \
{ \
- return sprintf(buffer, "%s\n", mk->mod->field); \
+ return scnprintf(buffer, PAGE_SIZE, "%s\n", mk->mod->field); \
} \
static int modinfo_##field##_exists(struct module *mod) \
{ \
OpenPOWER on IntegriCloud