LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: mingo@elte.hu, kyle@mcmartin.ca, linux-kernel@vger.kernel.org,
tglx@linutronix.de, mingo@redhat.com
Subject: Re: [PATCH] call sysrq_timer_list_show from a workqueue
Date: Tue, 8 Jan 2008 16:21:59 -0800 [thread overview]
Message-ID: <20080108162159.9f37d856.akpm@linux-foundation.org> (raw)
In-Reply-To: <200801082250.06828.rusty@rustcorp.com.au>
On Tue, 8 Jan 2008 22:50:06 +1100
Rusty Russell <rusty@rustcorp.com.au> wrote:
> On Tuesday 08 January 2008 22:33:23 Ingo Molnar wrote:
> > * Rusty Russell <rusty@rustcorp.com.au> wrote:
> > > +/* FIXME: Risky: returns a pointer into a module w/o lock */
> >
> > stupid question: since module unloads are so rare, why isnt this via the
> > same mechanism that CPU hotplug uses to securely unregister CPUs? I.e.
> > quiet all CPUs, disable irqs on all of them, then unlink the module.
>
> That's what we do. This old locking stuff is legacy.
>
> And here's the patch for the FIXME (which I put in to remind myself):
>
> Make module_address_lookup safe
>
> module_address_lookup releases preemption then returns a pointer into
> the module space. The only user (kallsyms) copies the result, so just
> do that under the preempt disable.
>
> ...
>
> -/* For kallsyms to ask for address resolution. NULL means not found.
> - We don't lock, as this is used for oops resolution and races are a
> - lesser concern. */
> -/* FIXME: Risky: returns a pointer into a module w/o lock */
> -const char *module_address_lookup(unsigned long addr,
> - unsigned long *size,
> - unsigned long *offset,
> - char **modname)
> +/* For kallsyms to ask for address resolution. NULL means not found. Careful
> + * not to lock to avoid deadlock on oopses, simply disable preemption. */
> +char *module_address_lookup(unsigned long addr,
> + unsigned long *size,
> + unsigned long *offset,
> + char **modname,
> + char *namebuf)
> {
> struct module *mod;
> const char *ret = NULL;
> @@ -2256,6 +2255,11 @@ const char *module_address_lookup(unsign
> ret = get_ksymbol(mod, addr, size, offset);
> break;
> }
> + }
> + /* Make a copy in here where it's safe */
> + if (ret) {
> + strncpy(namebuf, ret, KSYM_NAME_LEN - 1);
> + ret = namebuf;
> }
> preempt_enable();
> return ret;
The string handling in here has become a bit scruffy.
afacit the `namebuf[KSYM_NAME_LEN - 1] = 0;' would be unneeded if we were
to use strlcpy() and I suspect the `namebuf[0] = 0;' isn't needed either.
And the use of strlcpy() means we don't need to subtract 1 from
KSYM_NAME_LEN and we don't need to fret about weird strncpy semantics when
the input string is too large.
And the fact that incoming arg `namebuf' MUST point at a
KSYM_NAME_LEN-sized buffer could be better communicated by using a
dedicated struct for this, or by giving the arg a type of `char
namebuf[KSYM_NAME_LEN]'. Or by adding a comment. Or by just ignoring
me and doing something more useful.
next prev parent reply other threads:[~2008-01-09 0:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-08 6:31 Kyle McMartin
2008-01-08 9:17 ` Ingo Molnar
2008-01-08 11:28 ` Rusty Russell
2008-01-08 11:33 ` Ingo Molnar
2008-01-08 11:50 ` Rusty Russell
2008-01-08 15:51 ` Ingo Molnar
2008-01-08 22:48 ` Rusty Russell
2008-01-08 22:52 ` Ingo Molnar
2008-01-09 0:21 ` Andrew Morton [this message]
2008-01-09 3:20 ` Rusty Russell
2008-01-09 3:33 ` Andrew Morton
2008-01-09 4:27 ` Rusty Russell
2008-01-09 4:45 ` Andrew Morton
2008-01-09 15:24 ` Paulo Marques
2008-01-09 21:58 ` Rusty Russell
2008-01-08 14:41 ` Kyle McMartin
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=20080108162159.9f37d856.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=kyle@mcmartin.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
--subject='Re: [PATCH] call sysrq_timer_list_show from a workqueue' \
/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
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).