NULL terminate over-long /proc/kallsyms symbols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.)

(This patch has been ested on a 2.6.16 kernel.)

Signed-off-by: Andreas Gruenbacher <[email protected]>

Index: linux-2.6.17/kernel/module.c
===================================================================
--- linux-2.6.17.orig/kernel/module.c
+++ linux-2.6.17/kernel/module.c
@@ -1935,7 +1935,7 @@ struct module *module_get_kallsym(unsign
 		if (symnum < mod->num_symtab) {
 			*value = mod->symtab[symnum].st_value;
 			*type = mod->symtab[symnum].st_info;
-			strncpy(namebuf,
+			strlcpy(namebuf,
 				mod->strtab + mod->symtab[symnum].st_name,
 				127);
 			mutex_unlock(&module_mutex);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux