* [PATCH] Tell modpost that any reference from .note* is OK
@ 2007-05-29 20:33 Jeremy Fitzhardinge
2007-05-29 21:07 ` Sam Ravnborg
0 siblings, 1 reply; 3+ messages in thread
From: Jeremy Fitzhardinge @ 2007-05-29 20:33 UTC (permalink / raw)
To: Andi Kleen, Sam Ravnborg
Cc: Andrew Morton, Linux Kernel Mailing List, Eric W. Biederman
.note* sections are ELF notes, which are typically used by external
tools to examine the kernel image. Since this is removed from any
runtime consideration, it's OK to reference any section from a .note*
section.
As a side-effect, this changes secref_whitelist to accept a NULL "atsym"
pointer, allowing it to be called when "before" is NULL. This is
needed for .note sections since they don't necessarily have any
symbols, and it also allows the .got2 check to to be folded into the
normal whitelist checks.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
---
scripts/mod/modpost.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
===================================================================
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -639,6 +639,14 @@ static int strrcmp(const char *s, const
* powerpc has a machine desc table for each platform.
* It is mixture of function pointers of .init.text and .text.
* fromsec = .machvec | .machine.desc
+ *
+ * Pattern 11:
+ * Any reference from an ELF note section (.note*) to another section
+ * is OK. ELF notes are only used by tools inspecting the actual
+ * kernel image, so runtime access is not an issue.
+ *
+ * Pattern 12:
+ * powerpc has a GOT table in .got2 section
**/
static int secref_whitelist(const char *modname, const char *tosec,
const char *fromsec, const char *atsym,
@@ -675,7 +683,7 @@ static int secref_whitelist(const char *
f1 = 0;
if (strncmp(fromsec, ".data", strlen(".data")) != 0)
f1 = 0;
- if (strncmp(atsym, "__param", strlen("__param")) != 0)
+ if (!atsym || strncmp(atsym, "__param", strlen("__param")) != 0)
f1 = 0;
if (f1)
@@ -690,7 +698,7 @@ static int secref_whitelist(const char *
f2 = 0;
for (s = pat2sym; *s; s++)
- if (strrcmp(atsym, *s) == 0)
+ if (atsym && strrcmp(atsym, *s) == 0)
f1 = 1;
if (f1 && f2)
return 1;
@@ -720,6 +728,14 @@ static int secref_whitelist(const char *
/* Check for pattern 10 */
if ((strcmp(fromsec, ".machvec") == 0) ||
(strcmp(fromsec, ".machine.desc") == 0))
+ return 1;
+
+ /* Check for pattern 11 */
+ if (strncmp(fromsec, ".note", strlen(".note")) == 0)
+ return 1;
+
+ /* Check for pattern 12 */
+ if (strcmp(fromsec, ".got2") == 0)
return 1;
return 0;
@@ -848,14 +864,9 @@ static void warn_sec_mismatch(const char
refsymname = elf->strtab + refsym->st_name;
/* check whitelist - we may ignore it */
- if (before &&
- secref_whitelist(modname, secname, fromsec,
- elf->strtab + before->st_name, refsymname))
- return;
-
- /* fromsec whitelist - without a valid 'before'
- * powerpc has a GOT table in .got2 section */
- if (strcmp(fromsec, ".got2") == 0)
+ if (secref_whitelist(modname, secname, fromsec,
+ before ? (elf->strtab + before->st_name) : NULL,
+ refsymname))
return;
if (before && after) {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Tell modpost that any reference from .note* is OK
2007-05-29 20:33 [PATCH] Tell modpost that any reference from .note* is OK Jeremy Fitzhardinge
@ 2007-05-29 21:07 ` Sam Ravnborg
2007-05-29 21:13 ` Jeremy Fitzhardinge
0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2007-05-29 21:07 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Andi Kleen, Andrew Morton, Linux Kernel Mailing List,
Eric W. Biederman
On Tue, May 29, 2007 at 01:33:20PM -0700, Jeremy Fitzhardinge wrote:
> .note* sections are ELF notes, which are typically used by external
> tools to examine the kernel image. Since this is removed from any
> runtime consideration, it's OK to reference any section from a .note*
> section.
>
> As a side-effect, this changes secref_whitelist to accept a NULL "atsym"
> pointer, allowing it to be called when "before" is NULL. This is
> needed for .note sections since they don't necessarily have any
> symbols, and it also allows the .got2 check to to be folded into the
> normal whitelist checks.
I did it a bit different. Adding .note to init_section_ref_ok +
exit_section_ref_ok is much simpler.
Next patch will move .got2 there too.
Sam
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 662deba..b824198 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1139,6 +1139,7 @@ static int init_section_ref_ok(const char *name)
".debug",
".parainstructions",
".rodata",
+ ".note", /* ignore ELF notes - may contain anything */
NULL
};
/* part of section name */
@@ -1214,6 +1215,7 @@ static int exit_section_ref_ok(const char *name)
/* Start of section names */
const char *namelist2[] = {
".debug",
+ ".note", /* ignore ELF notes - may contain anything */
NULL
};
/* part of section name */
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Tell modpost that any reference from .note* is OK
2007-05-29 21:07 ` Sam Ravnborg
@ 2007-05-29 21:13 ` Jeremy Fitzhardinge
0 siblings, 0 replies; 3+ messages in thread
From: Jeremy Fitzhardinge @ 2007-05-29 21:13 UTC (permalink / raw)
To: Sam Ravnborg
Cc: Andi Kleen, Andrew Morton, Linux Kernel Mailing List,
Eric W. Biederman
Sam Ravnborg wrote:
> On Tue, May 29, 2007 at 01:33:20PM -0700, Jeremy Fitzhardinge wrote:
>
>> .note* sections are ELF notes, which are typically used by external
>> tools to examine the kernel image. Since this is removed from any
>> runtime consideration, it's OK to reference any section from a .note*
>> section.
>>
>> As a side-effect, this changes secref_whitelist to accept a NULL "atsym"
>> pointer, allowing it to be called when "before" is NULL. This is
>> needed for .note sections since they don't necessarily have any
>> symbols, and it also allows the .got2 check to to be folded into the
>> normal whitelist checks.
>>
>
> I did it a bit different. Adding .note to init_section_ref_ok +
> exit_section_ref_ok is much simpler.
> Next patch will move .got2 there too.
>
Oh, yeah, that's simpler. OK.
J
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-29 21:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-29 20:33 [PATCH] Tell modpost that any reference from .note* is OK Jeremy Fitzhardinge
2007-05-29 21:07 ` Sam Ravnborg
2007-05-29 21:13 ` Jeremy Fitzhardinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox