LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Robin Getz <rgetz@blackfin.uclinux.org>,
	rusty@rustcorp.com.au, linux-kernel@vger.kernel.org,
	Dave Hansen <haveblue@us.ibm.com>
Subject: Re: PATCH [1/1]: Don't return symbol lables in init sections after they have been freed
Date: Wed, 5 Mar 2008 21:13:37 -0800	[thread overview]
Message-ID: <20080306051337.GH16166@kroah.com> (raw)
In-Reply-To: <20080304160501.17d992f0.akpm@linux-foundation.org>

On Tue, Mar 04, 2008 at 04:05:01PM -0800, Andrew Morton wrote:
> On Tue, 4 Mar 2008 18:47:15 -0500
> Robin Getz <rgetz@blackfin.uclinux.org> wrote:
> 
> > From: Robin Getz <rgetz@blackfin.uclinux.org>
> > 
> > Today, when module names are looked up, we do not qualify them (check to see 
> > if the init section is still active or not). This can lead to problems when 
> > kernel modules get loaded into the same address that the kernel init section 
> > (or other module's init section was at). We sometimes return the old / no 
> > lomnger there 
> > 
> > This leads to bogus OOPS messages, and developers wasting their time looking 
> > for problems (in the kernel init section) where there are none (since it was 
> > a module).
> > 
> > This patch qualifies the addresses, to make sure the addresses are still valid 
> > before label/offset.
> > 
> > Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
> > 
> > ---
> > 
> >  linux-2.6.x/kernel/kallsyms.c |    3 ++-
> >  linux-2.6.x/kernel/module.c   |    3 ++-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > Index: linux-2.6.x/kernel/kallsyms.c
> > ===================================================================
> > --- linux-2.6.x/kernel/kallsyms.c	(revision 4212)
> > +++ linux-2.6.x/kernel/kallsyms.c	(working copy)
> > @@ -42,7 +42,8 @@
> >  
> >  static inline int is_kernel_inittext(unsigned long addr)
> >  {
> > -	if (addr >= (unsigned long)_sinittext
> > +	if (system_state == SYSTEM_BOOTING
> > +	    && addr >= (unsigned long)_sinittext
> >  	    && addr <= (unsigned long)_einittext)
> >  		return 1;
> >  	return 0;
> > Index: linux-2.6.x/kernel/module.c
> > ===================================================================
> > --- linux-2.6.x/kernel/module.c	(revision 4212)
> > +++ linux-2.6.x/kernel/module.c	(working copy)
> > @@ -2121,7 +2121,8 @@
> >  	struct module *mod;
> >  
> >  	list_for_each_entry(mod, &modules, list) {
> > -		if (within(addr, mod->module_init, mod->init_size)
> > +		if ((within(addr, mod->module_init, mod->init_size)
> > +		     && mod->state == MODULE_STATE_COMING)
> >  		    || within(addr, mod->module_core, mod->core_size)) {
> >  			if (modname)
> >  				*modname = mod->name;
> 
> Both of the above additions could do with a comment explaining what's going
> on.
> 
> The first one perhaps should use the more specific initmem_now_dynamic
> which is added by
> gregkh-driver-warn-when-statically-allocated-kobjects-are-used.patch from
> Greg's driver tree.  If the intent is to merge that - if not perhaps it can
> be split up.

The intent wasn't to merge that, as it seemed like a big hack.  But if
people don't mind, I have no objection to it going in.

thanks,

greg k-h

  reply	other threads:[~2008-03-06  5:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-04 23:47 Robin Getz
2008-03-05  0:05 ` Andrew Morton
2008-03-06  5:13   ` Greg KH [this message]
2008-03-05  1:43 ` Rusty Russell
2008-03-05 17:53   ` Robin Getz
2008-04-02 22:01   ` Robin Getz
2008-04-03 23:41     ` Rusty Russell
2008-04-05  5:13       ` Robin Getz
2008-04-06  4:14       ` Robin Getz

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=20080306051337.GH16166@kroah.com \
    --to=greg@kroah.com \
    --cc=akpm@linux-foundation.org \
    --cc=haveblue@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rgetz@blackfin.uclinux.org \
    --cc=rusty@rustcorp.com.au \
    --subject='Re: PATCH [1/1]: Don'\''t return symbol lables in init sections after they have been freed' \
    /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).