diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2006-07-14 03:24:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-15 00:53:52 -0400 |
commit | 098c5eea03de4707019a205140296893252b4130 (patch) | |
tree | 7fddd3a319c7607db2dd7082dcf3887c3e16b3c1 | |
parent | 329c6e4257d6a89990d72617d91437e2ce59e426 (diff) |
[PATCH] null-terminate over-long /proc/kallsyms symbols
Got a customer bug report (https://bugzilla.novell.com/190296) about kernel
symbols longer than 127 characters which end up in a string buffer that is
not NULL terminated, leading to garbage in /proc/kallsyms. Using strlcpy
prevents this from happening, even though such symbols still won't come out
right.
A better fix would be to not use a fixed-size buffer, but it's probably not
worth the trouble. (Modversion'ed symbols even have a length limit of 60.)
[bunk@stusta.de: build fix]
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | include/linux/module.h | 10 | ||||
-rw-r--r-- | kernel/kallsyms.c | 4 | ||||
-rw-r--r-- | kernel/module.c | 11 |
3 files changed, 10 insertions, 15 deletions
diff --git a/include/linux/module.h b/include/linux/module.h index d06c74fb8c26..0dfb794c52d3 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -362,10 +362,8 @@ int is_module_address(unsigned long addr); | |||
362 | 362 | ||
363 | /* Returns module and fills in value, defined and namebuf, or NULL if | 363 | /* Returns module and fills in value, defined and namebuf, or NULL if |
364 | symnum out of range. */ | 364 | symnum out of range. */ |
365 | struct module *module_get_kallsym(unsigned int symnum, | 365 | struct module *module_get_kallsym(unsigned int symnum, unsigned long *value, |
366 | unsigned long *value, | 366 | char *type, char *name, size_t namelen); |
367 | char *type, | ||
368 | char namebuf[128]); | ||
369 | 367 | ||
370 | /* Look for this name: can be of form module:name. */ | 368 | /* Look for this name: can be of form module:name. */ |
371 | unsigned long module_kallsyms_lookup_name(const char *name); | 369 | unsigned long module_kallsyms_lookup_name(const char *name); |
@@ -535,8 +533,8 @@ static inline const char *module_address_lookup(unsigned long addr, | |||
535 | 533 | ||
536 | static inline struct module *module_get_kallsym(unsigned int symnum, | 534 | static inline struct module *module_get_kallsym(unsigned int symnum, |
537 | unsigned long *value, | 535 | unsigned long *value, |
538 | char *type, | 536 | char *type, char *name, |
539 | char namebuf[128]) | 537 | size_t namelen) |
540 | { | 538 | { |
541 | return NULL; | 539 | return NULL; |
542 | } | 540 | } |
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 39277dd6bf90..ab16a5a4cfe9 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c | |||
@@ -275,8 +275,8 @@ static void upcase_if_global(struct kallsym_iter *iter) | |||
275 | static int get_ksymbol_mod(struct kallsym_iter *iter) | 275 | static int get_ksymbol_mod(struct kallsym_iter *iter) |
276 | { | 276 | { |
277 | iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms, | 277 | iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms, |
278 | &iter->value, | 278 | &iter->value, &iter->type, |
279 | &iter->type, iter->name); | 279 | iter->name, sizeof(iter->name)); |
280 | if (iter->owner == NULL) | 280 | if (iter->owner == NULL) |
281 | return 0; | 281 | return 0; |
282 | 282 | ||
diff --git a/kernel/module.c b/kernel/module.c index 35e1b1f859d7..2a19cd47c046 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -2019,10 +2019,8 @@ const char *module_address_lookup(unsigned long addr, | |||
2019 | return NULL; | 2019 | return NULL; |
2020 | } | 2020 | } |
2021 | 2021 | ||
2022 | struct module *module_get_kallsym(unsigned int symnum, | 2022 | struct module *module_get_kallsym(unsigned int symnum, unsigned long *value, |
2023 | unsigned long *value, | 2023 | char *type, char *name, size_t namelen) |
2024 | char *type, | ||
2025 | char namebuf[128]) | ||
2026 | { | 2024 | { |
2027 | struct module *mod; | 2025 | struct module *mod; |
2028 | 2026 | ||
@@ -2031,9 +2029,8 @@ struct module *module_get_kallsym(unsigned int symnum, | |||
2031 | if (symnum < mod->num_symtab) { | 2029 | if (symnum < mod->num_symtab) { |
2032 | *value = mod->symtab[symnum].st_value; | 2030 | *value = mod->symtab[symnum].st_value; |
2033 | *type = mod->symtab[symnum].st_info; | 2031 | *type = mod->symtab[symnum].st_info; |
2034 | strncpy(namebuf, | 2032 | strlcpy(name, mod->strtab + mod->symtab[symnum].st_name, |
2035 | mod->strtab + mod->symtab[symnum].st_name, | 2033 | namelen); |
2036 | 127); | ||
2037 | mutex_unlock(&module_mutex); | 2034 | mutex_unlock(&module_mutex); |
2038 | return mod; | 2035 | return mod; |
2039 | } | 2036 | } |