LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Robin Getz <rgetz@blackfin.uclinux.org>
To: "Rusty Russell" <rusty@rustcorp.com.au>
Cc: "LKML" <linux-kernel@vger.kernel.org>
Subject: Re: PATCH [1/1]: Don't return symbol lables in init sections after they have been freed
Date: Sun, 6 Apr 2008 00:14:41 -0400	[thread overview]
Message-ID: <200804060014.41440.rgetz@blackfin.uclinux.org> (raw)
In-Reply-To: <200804040941.42275.rusty@rustcorp.com.au>

On Thu 3 Apr 2008 19:41, Rusty Russell pondered:
> On Thursday 03 April 2008 08:01:25 Robin Getz wrote:
> > On Tue 4 Mar 2008 20:43, Rusty Russell pondered:
> > >     As to the actual patch, your kallsyms.c patch matches
> > > a2da4052f1df6bc77749f84496fe731ab8b458f7's change to extable.c: please
> > > resubmit with just that one.  For bonus points, look at combining the
> > > extable and kallsyms logic so we don't diverge in future...
> >
> > OK since this took so long, I went for bonus points...
> 
> Looks good.  I don't have extratext in my kernel tho 
> (v2.6.25-rc8-139-ge315c12).  Otherwise I'd suspect it should be consistently 
> used between extable and kallsyms.

update patch - refactored a bit more - all address checking is removed from
kallsyms, and moved to extable - if this looks ok - I will send it properly...


Index: linux-2.6.x/kernel/kallsyms.c
===================================================================
--- linux-2.6.x/kernel/kallsyms.c	(revision 4546)
+++ linux-2.6.x/kernel/kallsyms.c	(working copy)
@@ -45,38 +45,20 @@
 
 extern const unsigned long kallsyms_markers[] __attribute__((weak));
 
-static inline int is_kernel_inittext(unsigned long addr)
+static int is_ksym_addr(unsigned long addr)
 {
-	if (addr >= (unsigned long)_sinittext
-	    && addr <= (unsigned long)_einittext)
-		return 1;
-	return 0;
-}
+	if (all_var) {
+		if (core_kernel_anywhere(addr))
+			return 1;
 
-static inline int is_kernel_text(unsigned long addr)
-{
-	if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext)
-		return 1;
-	return in_gate_area_no_task(addr);
-}
+		return in_gate_area_no_task(addr);
+	}
 
-static inline int is_kernel(unsigned long addr)
-{
-	if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
+	if (core_kernel_text(addr))
 		return 1;
+
 	return in_gate_area_no_task(addr);
-}
 
-static int is_ksym_addr(unsigned long addr)
-{
-	if (all_var)
-		return is_kernel(addr);
-
-	return is_kernel_text(addr) || is_kernel_inittext(addr);
 }
 
 /* expand a compressed symbol data into the resulting uncompressed string,
@@ -206,7 +188,7 @@
 
 	/* if we found no next symbol, we use the end of the section */
 	if (!symbol_end) {
-		if (is_kernel_inittext(addr))
+		if (core_kernel_inittext(addr))
 			symbol_end = (unsigned long)_einittext;
 		else if (all_var)
 			symbol_end = (unsigned long)_end;
Index: linux-2.6.x/kernel/extable.c
===================================================================
--- linux-2.6.x/kernel/extable.c	(revision 4541)
+++ linux-2.6.x/kernel/extable.c	(working copy)
@@ -40,18 +40,43 @@
 	return e;
 }
 
-int core_kernel_text(unsigned long addr)
+int core_kernel_inittext(unsigned long addr)
 {
+	if (addr >= (unsigned long)_sinittext &&
+	    addr <= (unsigned long)_einittext)
+		return 1;
+	return 0;
+}
+
+#ifdef CONFIG_KALLSYMS_ALL
+int core_kernel_anywhere(unsigned long addr)
+{
+	if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
+		return 1;
+	return 0;
+}
+#endif
+
+int __core_kernel_text(unsigned long addr)
+{
 	if (addr >= (unsigned long)_stext &&
 	    addr <= (unsigned long)_etext)
 		return 1;
 
-	if (addr >= (unsigned long)_sinittext &&
-	    addr <= (unsigned long)_einittext)
- 		return 1;

 	return 0;
 }
 
+int core_kernel_text(unsigned long addr)
+{
+	return __core_kernel_text(addr) || core_kernel_inittext(addr);
+}
+
 int __kernel_text_address(unsigned long addr)
 {
 	if (core_kernel_text(addr))
@@ -65,3 +90,4 @@
 		return 1;
 	return module_text_address(addr) != NULL;
 }
+
Index: linux-2.6.x/include/linux/kernel.h
===================================================================
--- linux-2.6.x/include/linux/kernel.h	(revision 4541)
+++ linux-2.6.x/include/linux/kernel.h	(working copy)
@@ -167,6 +167,8 @@
 extern unsigned long long memparse(char *ptr, char **retptr);
 
 extern int core_kernel_text(unsigned long addr);
+extern int core_kernel_inittext(unsigned long addr);
+extern int core_kernel_anywhere(unsigned long addr);
 extern int __kernel_text_address(unsigned long addr);
 extern int kernel_text_address(unsigned long addr);
 struct pid;

      parent reply	other threads:[~2008-04-06  4:18 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
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 [this message]

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=200804060014.41440.rgetz@blackfin.uclinux.org \
    --to=rgetz@blackfin.uclinux.org \
    --cc=linux-kernel@vger.kernel.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).