public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruen@suse.de>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: NULL terminate over-long /proc/kallsyms symbols
Date: Wed, 5 Jul 2006 18:59:41 +0200	[thread overview]
Message-ID: <200607051859.41638.agruen@suse.de> (raw)

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 <agruen@suse.de>

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

             reply	other threads:[~2006-07-05 16:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-05 16:59 Andreas Gruenbacher [this message]
2006-07-05 17:03 ` NULL terminate over-long /proc/kallsyms symbols Daniel Bonekeeper
2006-07-05 17:06   ` Christoph Hellwig
2006-07-06 18:00   ` Avi Kivity
2006-07-05 17:13 ` Andreas Schwab
2006-07-05 19:34 ` Andrew Morton
2006-07-05 19:42   ` Andreas Gruenbacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200607051859.41638.agruen@suse.de \
    --to=agruen@suse.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox