linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Mundt <lethal@linux-sh.org>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>, linux-next@vger.kernel.org
Subject: [PATCH] kallsyms: Fix segfault in prefix_underscores_count().
Date: Fri, 7 Aug 2009 18:22:31 +0900	[thread overview]
Message-ID: <20090807092231.GA2199@linux-sh.org> (raw)

As a good indicator that Impact lines are completely useless, commit 
b478b782e110fdb4135caa3062b6d687e989d994 "kallsyms, tracing: output more
proper symbol name" introduces a "bugfix" that introduced segfaults on
several of my defconfigs:

	http://kisskb.ellerman.id.au/kisskb/buildresult/1017849/
	http://kisskb.ellerman.id.au/kisskb/buildresult/1017351/
	http://kisskb.ellerman.id.au/kisskb/buildresult/1017354/

The cause is the introduction of prefix_underscores_count() which
attempts to count underscores.. even in symbols that do not have them.
As a result, it just uselessly runs past the end of the buffer until it
crashes.

This adds a strlen iterator that bails out if nothing is found in the
string, which fixes up the observed segfaults.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Sam Ravnborg <sam@ravnborg.org>

---

I've uploaded the symbol list to:

	http://userweb.kernel.org/~lethal/symbol-list.gz

that one can pipe in to scripts/kallsyms to reproduce the fault in -next,
incase someone wants to come up with a better fix :-)

 scripts/kallsyms.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 64343cc..f1d44b2 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -584,9 +538,14 @@ static int may_be_linker_script_provide_symbol(const struct sym_entry *se)
 static int prefix_underscores_count(const char *str)
 {
 	const char *tail = str;
+	size_t len = strlen(str);
+
+	while (*tail != '_') {
+		if (!len--)
+			return 0;
 
-	while (*tail != '_')
 		tail++;
+	}
 
 	return tail - str;
 }

                 reply	other threads:[~2009-08-07  9:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090807092231.GA2199@linux-sh.org \
    --to=lethal@linux-sh.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-next@vger.kernel.org \
    --cc=sam@ravnborg.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;
as well as URLs for NNTP newsgroup(s).