public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Joe Perches <joe@perches.com>, Sam Ravnborg <sam@ravnborg.org>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Zhaolei <zhaolei@cn.fujitsu.com>,
	Tom Zanussi <tzanussi@gmail.com>, Li Zefan <lizf@cn.fujitsu.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: RFC: introduce struct ksymbol
Date: Wed, 15 Apr 2009 08:31:06 +0200	[thread overview]
Message-ID: <20090415063106.GC12040@elte.hu> (raw)
In-Reply-To: <84144f020904142313m4da323fdj9a8becf3010c519c@mail.gmail.com>


* Pekka Enberg <penberg@cs.helsinki.fi> wrote:

> Hi Ingo,
> 
> On Wed, Apr 15, 2009 at 8:58 AM, Ingo Molnar <mingo@elte.hu> wrote:
> >
> > (Sam and Rusty Cc:-ed)
> >
> > * Joe Perches <joe@perches.com> wrote:
> >
> >> On Wed, 2009-04-15 at 02:00 +0200, Frederic Weisbecker wrote:
> >> > arch/blackfin/kernel/traps.c:   symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
> >> > arch/powerpc/xmon/xmon.c:               name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr);
> >> > arch/sh/kernel/cpu/sh5/unwind.c:        sym = kallsyms_lookup(pc, NULL, &offset, NULL, namebuf);
> >> > arch/x86/kernel/ftrace.c:       kallsyms_lookup((unsigned long) syscall, NULL, NULL, NULL, str);
> >> > kernel/kprobes.c:               sym = kallsyms_lookup((unsigned long)p->addr, NULL,
> >> > kernel/lockdep.c:       return kallsyms_lookup((unsigned long)key, NULL, NULL, NULL, str);
> >> > kernel/trace/ftrace.c:  kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
> >> > kernel/trace/ftrace.c:  kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
> >> > kernel/trace/ftrace.c:  kallsyms_lookup((unsigned long)rec->ops->func, NULL, NULL, NULL, str);
> >> > kernel/trace/ftrace.c:  kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
> >> > kernel/trace/ftrace.c:  kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
> >> > kernel/trace/ftrace.c:  kallsyms_lookup(rec->ip, NULL, NULL, &modname, str);
> >> > kernel/trace/ftrace.c:  kallsyms_lookup(*ptr, NULL, NULL, NULL, str);
> >> > kernel/trace/trace_functions.c: kallsyms_lookup(ip, NULL, NULL, NULL, str);
> >> > kernel/trace/trace_output.c:    kallsyms_lookup(address, NULL, NULL, NULL, str);
> >>
> >> Perhaps a conversion from
> >>
> >> "char str[KSYM_SYMBOL_LEN]"
> >> to
> >> "struct ksymbol sym"?
> >>
> >> could be useful.
> >>
> >> There are a few places that use a hard coded length of 128
> >> instead of KSYM_SYMBOL_LENGTH that are also converted.
> >>
> >> Compile tested only
> >
> > Why not 'struct ksym'? That name is unused right now, it is shorter
> > and just as descriptive.
> >
> > Regarding the change... dunno. Sam, Rusty - what do you think?
> >
> > Downsides would be loss of awareness of stack footprint impact. A
> > plain struct is easy to slap on, and it's not immediately visible
> > that it carries 128 bytes of weight. It might also be confusing in
> > terms of the nature of the interface - whether it's a pointery
> > object or not.
> >
> > Prior use:
> >
> >        char str[KSYM_SYMBOL_LEN];
> >
> >        kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
> >
> > New use:
> >
> >        struct ksym sym;
> >
> >        kallsyms_lookup(rec->ip, NULL, NULL, NULL, &sym);
> >
> > Dunno.
> 
> The change makes sense to me. Passing a raw char pointer down the 
> call-chain is a buffer overflow waiting to happen and as a matter 
> of fact, we've had bugs in this area before. See commit 
> 9c24624727f6d6c460e45762a408ca5f5b9b8ef2 ("KSYM_SYMBOL_LEN fixes") 
> for an example.

OK.

Albeit i think that particular bug happened due to the ambigious 
namingof KSYM_SYMBOL_LEN versus KSYM_NAME_LEN. Who would have 
thought that there's a difference between the two and that there's a 
'ksym symbol' versus 'ksym name' distinction?

It would be more robust to have just one length (the longer one), 
and maybe have the shorter one as __KSYM_NAME_LEN - for expert use.

	Ingo

  reply	other threads:[~2009-04-15  6:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-15  0:00 [PATCH] vsprintf: introduce %pf Frederic Weisbecker
2009-04-15  0:09 ` Joe Perches
2009-04-15  0:13   ` Frederic Weisbecker
2009-04-15  1:57 ` Zhaolei
2009-04-15 15:26   ` Frederic Weisbecker
2009-04-15  2:17 ` Mike Frysinger
2009-04-15  2:38   ` Steven Rostedt
2009-04-15  3:13     ` KOSAKI Motohiro
2009-04-15 15:48     ` [PATCH v2] " Frederic Weisbecker
2009-04-18 17:51       ` Mike Frysinger
2009-04-29 19:09       ` [tip:core/printk] vsprintf: introduce %pf format specifier tip-bot for Frederic Weisbecker
2009-04-15 15:29   ` [PATCH] vsprintf: introduce %pf Frederic Weisbecker
2009-04-15  5:03 ` RFC: introduce struct ksymbol Joe Perches
2009-04-15  5:58   ` Ingo Molnar
2009-04-15  6:13     ` Pekka Enberg
2009-04-15  6:31       ` Ingo Molnar [this message]
2009-04-15 15:52         ` Frederic Weisbecker
2009-04-15  6:14     ` Joe Perches
2009-04-15 10:51     ` Rusty Russell
2009-04-17  7:55       ` Joe Perches
2009-04-18 16:09         ` Frederic Weisbecker
2009-04-19  2:05           ` Joe Perches
2009-04-23  1:31           ` Joe Perches

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=20090415063106.GC12040@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=penberg@cs.helsinki.fi \
    --cc=rostedt@goodmis.org \
    --cc=rusty@rustcorp.com.au \
    --cc=sam@ravnborg.org \
    --cc=tzanussi@gmail.com \
    --cc=zhaolei@cn.fujitsu.com \
    /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