Skip to contentSkip to conversation

x86, relocs: add percpu fixup for GNU ld 2.23

PATCH In review Kees Cook 3 participants 5 messages Oct 16, 2013 – Oct 18, 2013 x86

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 x86, relocs: add percpu fixup for GNU ld 2.23

The GNU linker tries to put __per_cpu_load into the percpu area, resulting in a lack of its relocation. Force this symbol to be relocated. Seen starting with GNU ld 2.23 and later.

---
 arch/x86/tools/relocs.c |    2 ++
 1 file changed, 2 insertions(+)
arch/x86/tools/relocs.c +2 -0
index 1fa291f..7a85f29 100644
@@ -729,6 +729,7 @@ static void percpu_init(void)
  *
  * The GNU linker incorrectly associates:
  *	__init_begin
+ *	__per_cpu_load
  *
  * The "gold" linker incorrectly associates:
  *	init_per_cpu__irq_stack_union
@@ -738,6 +739,7 @@ static int is_percpu_sym(ElfW(Sym) *sym, const char *symname)
 {
 	return (sym->st_shndx == per_cpu_shndx) &&
 		strcmp(symname, "__init_begin") &&
+		strcmp(symname, "__per_cpu_load") &&
 		strncmp(symname, "init_per_cpu_", 13);
 }
 
Signature · 6 lines
1.7.9.5


-- 
Kees Cook
Chrome OS Security
#1 lore raw
Quoted 24 lines · Kees Cook

The GNU linker tries to put __per_cpu_load into the percpu area, resulting in a lack of its relocation. Force this symbol to be relocated. Seen starting with GNU ld 2.23 and later.

---
 arch/x86/tools/relocs.c |    2 ++
 1 file changed, 2 insertions(+)
arch/x86/tools/relocs.c +1 -0
index 1fa291f..7a85f29 100644
@@ -729,6 +729,7 @@ static void percpu_init(void)
  *
  * The GNU linker incorrectly associates:
  *	__init_begin
+ *	__per_cpu_load
  *
  * The "gold" linker incorrectly associates:
  *	init_per_cpu__irq_stack_union

arch/x86/tools/relocs.c static int is_percpu_sym(ElfW(Sym) *sym, const char *symname) · line 745

Quoted 7 lines
arch/x86/tools/relocs.c +1 -0
@@ -738,6 +739,7 @@ static int is_percpu_sym(ElfW(Sym) *sym, const char *symname)
 {
 	return (sym->st_shndx == per_cpu_shndx) &&
 		strcmp(symname, "__init_begin") &&
+		strcmp(symname, "__per_cpu_load") &&
 		strncmp(symname, "init_per_cpu_", 13);
 }
 

Why isn't this list using a regex like other symbol classes?

-hpa

author
#2 lore raw
Quoted 26 lines · H. Peter Anvin
Quoted 25 lines · Kees Cook

The GNU linker tries to put __per_cpu_load into the percpu area, resulting in a lack of its relocation. Force this symbol to be relocated. Seen starting with GNU ld 2.23 and later.

---
 arch/x86/tools/relocs.c |    2 ++
 1 file changed, 2 insertions(+)
arch/x86/tools/relocs.c +1 -0
index 1fa291f..7a85f29 100644
@@ -729,6 +729,7 @@ static void percpu_init(void)
  *
  * The GNU linker incorrectly associates:
  *   __init_begin
+ *   __per_cpu_load
  *
  * The "gold" linker incorrectly associates:
  *   init_per_cpu__irq_stack_union
@@ -738,6 +739,7 @@ static int is_percpu_sym(ElfW(Sym) *sym, const char *symname)
 {
      return (sym->st_shndx == per_cpu_shndx) &&
Quoted 8 lines

arch/x86/tools/relocs.c static int is_percpu_sym(ElfW(Sym) *sym, const char *symname) · line 745

Quoted 6 lines
arch/x86/tools/relocs.c +1 -0
              strcmp(symname, "__init_begin") &&
+             strcmp(symname, "__per_cpu_load") &&
              strncmp(symname, "init_per_cpu_", 13);
 }
 

Why isn't this list using a regex like other symbol classes?

I assume because it was initially a single item and it has grown slowly. Would you like me to convert it to a regex instead?

-Kees

Signature · 2 lines
Kees Cook
Chrome OS Security
#3 lore raw
Quoted 6 lines · Kees Cook
Quoted 2 lines

Why isn't this list using a regex like other symbol classes?

I assume because it was initially a single item and it has grown slowly. Would you like me to convert it to a regex instead?

Yes, please.

-hpa

#4 lore raw

[tip:x86/kaslr] x86/relocs: Add percpu fixup for GNU ld 2.23

In reply to Kees Cook
x86/relocs: Add percpu fixup for GNU ld 2.23
Commit-ID:  aec58bafaf89279522c44ec8ca9211eabb2b6976
Gitweb:     http://git.kernel.org/tip/aec58bafaf89279522c44ec8ca9211eabb2b6976
Author:     Kees Cook <[email protected]>
AuthorDate: Tue, 15 Oct 2013 23:43:14 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 18 Oct 2013 08:45:09 +0200

x86/relocs: Add percpu fixup for GNU ld 2.23

The GNU linker tries to put __per_cpu_load into the percpu area, resulting in a lack of its relocation. Force this symbol to be relocated. Seen starting with GNU ld 2.23 and later.

---
 arch/x86/tools/relocs.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/tools/relocs.c +2 -0
index 71a2533..11f9285 100644
@@ -729,6 +729,7 @@ static void percpu_init(void)
  *
  * The GNU linker incorrectly associates:
  *	__init_begin
+ *	__per_cpu_load
  *
  * The "gold" linker incorrectly associates:
  *	init_per_cpu__irq_stack_union
@@ -738,6 +739,7 @@ static int is_percpu_sym(ElfW(Sym) *sym, const char *symname)
 {
 	return (sym->st_shndx == per_cpu_shndx) &&
 		strcmp(symname, "__init_begin") &&
+		strcmp(symname, "__per_cpu_load") &&
 		strncmp(symname, "init_per_cpu_", 13);
 }