[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>
This commit is contained in:

committed by
Linus Torvalds

parent
329c6e4257
commit
098c5eea03
@@ -2019,10 +2019,8 @@ const char *module_address_lookup(unsigned long addr,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct module *module_get_kallsym(unsigned int symnum,
|
||||
unsigned long *value,
|
||||
char *type,
|
||||
char namebuf[128])
|
||||
struct module *module_get_kallsym(unsigned int symnum, unsigned long *value,
|
||||
char *type, char *name, size_t namelen)
|
||||
{
|
||||
struct module *mod;
|
||||
|
||||
@@ -2031,9 +2029,8 @@ struct module *module_get_kallsym(unsigned int symnum,
|
||||
if (symnum < mod->num_symtab) {
|
||||
*value = mod->symtab[symnum].st_value;
|
||||
*type = mod->symtab[symnum].st_info;
|
||||
strncpy(namebuf,
|
||||
mod->strtab + mod->symtab[symnum].st_name,
|
||||
127);
|
||||
strlcpy(name, mod->strtab + mod->symtab[symnum].st_name,
|
||||
namelen);
|
||||
mutex_unlock(&module_mutex);
|
||||
return mod;
|
||||
}
|
||||
|
Reference in New Issue
Block a user