* [PATCH 0/4] objtool: seg fault fixes and retpoline improvements
@ 2018-01-30 4:00 Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 1/4] objtool: Improve retpoline alternative handling Josh Poimboeuf
` (3 more replies)
0 siblings, 4 replies; 15+ messages in thread
From: Josh Poimboeuf @ 2018-01-30 4:00 UTC (permalink / raw)
To: x86
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, David Woodhouse,
Guenter Roeck
Some assorted fixes and improvements.
Josh Poimboeuf (4):
objtool: Improve retpoline alternative handling
objtool: Add support for alternatives at the end of a section
objtool: Warn on stripped section symbol
objtool: Don't print '.tmp_' prefix for .o files
tools/objtool/check.c | 110 ++++++++++++++++++++++++++++++------------------
tools/objtool/orc_gen.c | 5 +++
2 files changed, 73 insertions(+), 42 deletions(-)
--
2.14.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/4] objtool: Improve retpoline alternative handling
2018-01-30 4:00 [PATCH 0/4] objtool: seg fault fixes and retpoline improvements Josh Poimboeuf
@ 2018-01-30 4:00 ` Josh Poimboeuf
2018-01-30 8:46 ` [tip:x86/pti] " tip-bot for Josh Poimboeuf
2018-01-30 14:12 ` tip-bot for Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 2/4] objtool: Add support for alternatives at the end of a section Josh Poimboeuf
` (2 subsequent siblings)
3 siblings, 2 replies; 15+ messages in thread
From: Josh Poimboeuf @ 2018-01-30 4:00 UTC (permalink / raw)
To: x86
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, David Woodhouse,
Guenter Roeck
Currently objtool requires all retpolines to be
a) patched in with alternatives; and
b) annotated with ANNOTATE_NOSPEC_ALTERNATIVE.
If you forget to do both of the above, objtool seg faults trying to
dereference a NULL 'insn->call_dest' pointer.
Avoid that situation and print a more helpful error message:
quirks.o: warning: objtool: efi_delete_dummy_variable()+0x99: unsupported intra-function call
quirks.o: warning: objtool: If this is a retpoline, please patch it in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE.
Future improvements can be made to make objtool smarter with respect to
retpolines, but this is a good incremental improvement for now.
Reported-and-tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
tools/objtool/check.c | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index f40d46e24bcc..bc3490d929ff 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -543,18 +543,14 @@ static int add_call_destinations(struct objtool_file *file)
dest_off = insn->offset + insn->len + insn->immediate;
insn->call_dest = find_symbol_by_offset(insn->sec,
dest_off);
- /*
- * FIXME: Thanks to retpolines, it's now considered
- * normal for a function to call within itself. So
- * disable this warning for now.
- */
-#if 0
- if (!insn->call_dest) {
- WARN_FUNC("can't find call dest symbol at offset 0x%lx",
- insn->sec, insn->offset, dest_off);
+
+ if (!insn->call_dest && !insn->ignore) {
+ WARN_FUNC("unsupported intra-function call",
+ insn->sec, insn->offset);
+ WARN("If this is a retpoline, please patch it in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE.");
return -1;
}
-#endif
+
} else if (rela->sym->type == STT_SECTION) {
insn->call_dest = find_symbol_by_offset(rela->sym->sec,
rela->addend+4);
@@ -648,6 +644,8 @@ static int handle_group_alt(struct objtool_file *file,
last_new_insn = insn;
+ insn->ignore = orig_insn->ignore_alts;
+
if (insn->type != INSN_JUMP_CONDITIONAL &&
insn->type != INSN_JUMP_UNCONDITIONAL)
continue;
@@ -729,10 +727,6 @@ static int add_special_section_alts(struct objtool_file *file)
goto out;
}
- /* Ignore retpoline alternatives. */
- if (orig_insn->ignore_alts)
- continue;
-
new_insn = NULL;
if (!special_alt->group || special_alt->new_len) {
new_insn = find_insn(file, special_alt->new_sec,
@@ -1089,11 +1083,11 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
- ret = add_call_destinations(file);
+ ret = add_special_section_alts(file);
if (ret)
return ret;
- ret = add_special_section_alts(file);
+ ret = add_call_destinations(file);
if (ret)
return ret;
@@ -1720,10 +1714,12 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
insn->visited = true;
- list_for_each_entry(alt, &insn->alts, list) {
- ret = validate_branch(file, alt->insn, state);
- if (ret)
- return 1;
+ if (!insn->ignore_alts) {
+ list_for_each_entry(alt, &insn->alts, list) {
+ ret = validate_branch(file, alt->insn, state);
+ if (ret)
+ return 1;
+ }
}
switch (insn->type) {
--
2.14.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/4] objtool: Add support for alternatives at the end of a section
2018-01-30 4:00 [PATCH 0/4] objtool: seg fault fixes and retpoline improvements Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 1/4] objtool: Improve retpoline alternative handling Josh Poimboeuf
@ 2018-01-30 4:00 ` Josh Poimboeuf
2018-01-30 8:46 ` [tip:x86/pti] " tip-bot for Josh Poimboeuf
2018-01-30 14:13 ` tip-bot for Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 3/4] objtool: Warn on stripped section symbol Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files Josh Poimboeuf
3 siblings, 2 replies; 15+ messages in thread
From: Josh Poimboeuf @ 2018-01-30 4:00 UTC (permalink / raw)
To: x86
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, David Woodhouse,
Guenter Roeck
Now that the previous patch gave objtool the ability to read retpoline
alternatives, it shows a new warning:
arch/x86/entry/entry_64.o: warning: objtool: .entry_trampoline: don't know how to handle alternatives at end of section
This is due to the JMP_NOSPEC in entry_SYSCALL_64_trampoline().
Previously, objtool ignored this situation because it wasn't needed, and
it would have required a bit of extra code. Now that this case exists,
add proper support for it.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
tools/objtool/check.c | 53 ++++++++++++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 22 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index bc3490d929ff..9cd028aa1509 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -594,7 +594,7 @@ static int handle_group_alt(struct objtool_file *file,
struct instruction *orig_insn,
struct instruction **new_insn)
{
- struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump;
+ struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump = NULL;
unsigned long dest_off;
last_orig_insn = NULL;
@@ -610,28 +610,30 @@ static int handle_group_alt(struct objtool_file *file,
last_orig_insn = insn;
}
- if (!next_insn_same_sec(file, last_orig_insn)) {
- WARN("%s: don't know how to handle alternatives at end of section",
- special_alt->orig_sec->name);
- return -1;
- }
-
- fake_jump = malloc(sizeof(*fake_jump));
- if (!fake_jump) {
- WARN("malloc failed");
- return -1;
+ if (next_insn_same_sec(file, last_orig_insn)) {
+ fake_jump = malloc(sizeof(*fake_jump));
+ if (!fake_jump) {
+ WARN("malloc failed");
+ return -1;
+ }
+ memset(fake_jump, 0, sizeof(*fake_jump));
+ INIT_LIST_HEAD(&fake_jump->alts);
+ clear_insn_state(&fake_jump->state);
+
+ fake_jump->sec = special_alt->new_sec;
+ fake_jump->offset = -1;
+ fake_jump->type = INSN_JUMP_UNCONDITIONAL;
+ fake_jump->jump_dest = list_next_entry(last_orig_insn, list);
+ fake_jump->ignore = true;
}
- memset(fake_jump, 0, sizeof(*fake_jump));
- INIT_LIST_HEAD(&fake_jump->alts);
- clear_insn_state(&fake_jump->state);
-
- fake_jump->sec = special_alt->new_sec;
- fake_jump->offset = -1;
- fake_jump->type = INSN_JUMP_UNCONDITIONAL;
- fake_jump->jump_dest = list_next_entry(last_orig_insn, list);
- fake_jump->ignore = true;
if (!special_alt->new_len) {
+ if (!fake_jump) {
+ WARN("%s: empty alternative at end of section",
+ special_alt->orig_sec->name);
+ return -1;
+ }
+
*new_insn = fake_jump;
return 0;
}
@@ -654,8 +656,14 @@ static int handle_group_alt(struct objtool_file *file,
continue;
dest_off = insn->offset + insn->len + insn->immediate;
- if (dest_off == special_alt->new_off + special_alt->new_len)
+ if (dest_off == special_alt->new_off + special_alt->new_len) {
+ if (!fake_jump) {
+ WARN("%s: alternative jump to end of section",
+ special_alt->orig_sec->name);
+ return -1;
+ }
insn->jump_dest = fake_jump;
+ }
if (!insn->jump_dest) {
WARN_FUNC("can't find alternative jump destination",
@@ -670,7 +678,8 @@ static int handle_group_alt(struct objtool_file *file,
return -1;
}
- list_add(&fake_jump->list, &last_new_insn->list);
+ if (fake_jump)
+ list_add(&fake_jump->list, &last_new_insn->list);
return 0;
}
--
2.14.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/4] objtool: Warn on stripped section symbol
2018-01-30 4:00 [PATCH 0/4] objtool: seg fault fixes and retpoline improvements Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 1/4] objtool: Improve retpoline alternative handling Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 2/4] objtool: Add support for alternatives at the end of a section Josh Poimboeuf
@ 2018-01-30 4:00 ` Josh Poimboeuf
2018-01-30 8:47 ` [tip:x86/pti] " tip-bot for Josh Poimboeuf
2018-01-30 14:13 ` tip-bot for Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files Josh Poimboeuf
3 siblings, 2 replies; 15+ messages in thread
From: Josh Poimboeuf @ 2018-01-30 4:00 UTC (permalink / raw)
To: x86
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, David Woodhouse,
Guenter Roeck
With the following fix:
2a0098d70640 ("objtool: Fix seg fault with gold linker")
... a seg fault was avoided, but the original seg fault condition in
objtool wasn't fixed. Replace the seg fault with an error message.
Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
tools/objtool/orc_gen.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
index e61fe703197b..18384d9be4e1 100644
--- a/tools/objtool/orc_gen.c
+++ b/tools/objtool/orc_gen.c
@@ -98,6 +98,11 @@ static int create_orc_entry(struct section *u_sec, struct section *ip_relasec,
struct orc_entry *orc;
struct rela *rela;
+ if (!insn_sec->sym) {
+ WARN("missing symbol for section %s", insn_sec->name);
+ return -1;
+ }
+
/* populate ORC data */
orc = (struct orc_entry *)u_sec->data->d_buf + idx;
memcpy(orc, o, sizeof(*orc));
--
2.14.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files
2018-01-30 4:00 [PATCH 0/4] objtool: seg fault fixes and retpoline improvements Josh Poimboeuf
` (2 preceding siblings ...)
2018-01-30 4:00 ` [PATCH 3/4] objtool: Warn on stripped section symbol Josh Poimboeuf
@ 2018-01-30 4:00 ` Josh Poimboeuf
2018-01-30 8:47 ` [tip:x86/pti] objtool: Don't print '.tmp_' prefix for .o files when CONFIG_MODVERSIONS=y tip-bot for Josh Poimboeuf
2018-01-30 9:58 ` [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files Peter Zijlstra
3 siblings, 2 replies; 15+ messages in thread
From: Josh Poimboeuf @ 2018-01-30 4:00 UTC (permalink / raw)
To: x86
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, David Woodhouse,
Guenter Roeck
With the following commit:
2a0098d70640 ("objtool: Fix seg fault with gold linker")
... objtool warnings started showing the modversions '.tmp_' prefix in
the .o file name, like:
arch/x86/mm/.tmp_mem_encrypt_boot.o: warning: objtool: sme_encrypt_execute()+0x48: indirect call found in RETPOLINE build
The prefix is confusing. Remove it from the printed 'objname' variable.
Fixes: 2a0098d70640 ("objtool: Fix seg fault with gold linker")
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
tools/objtool/check.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 9cd028aa1509..0bf61db0498a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1978,6 +1978,25 @@ static void cleanup(struct objtool_file *file)
elf_close(file->elf);
}
+/*
+ * With CONFIG_MODVERSIONS, the object name has '.tmp_' prepended to it.
+ * After the file has been opened, remove the prefix so warnings will look
+ * sensible.
+ */
+static void fix_objname(void)
+{
+ char *s;
+
+ s = strstr(objname, ".tmp_");
+ if (!s)
+ return;
+
+ for (; s[5]; s++)
+ s[0] = s[5];
+
+ s[0] = 0;
+}
+
int check(const char *_objname, bool _no_fp, bool no_unreachable, bool orc)
{
struct objtool_file file;
@@ -1990,6 +2009,8 @@ int check(const char *_objname, bool _no_fp, bool no_unreachable, bool orc)
if (!file.elf)
return 1;
+ fix_objname();
+
INIT_LIST_HEAD(&file.insn_list);
hash_init(file.insn_hash);
file.whitelist = find_section_by_name(file.elf, ".discard.func_stack_frame_non_standard");
--
2.14.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [tip:x86/pti] objtool: Improve retpoline alternative handling
2018-01-30 4:00 ` [PATCH 1/4] objtool: Improve retpoline alternative handling Josh Poimboeuf
@ 2018-01-30 8:46 ` tip-bot for Josh Poimboeuf
2018-01-30 14:12 ` tip-bot for Josh Poimboeuf
1 sibling, 0 replies; 15+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2018-01-30 8:46 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, gregkh, linux-kernel, bp, dave.hansen, tglx, peterz,
jpoimboe, luto, linux, jgross, dwmw2, hpa, torvalds
Commit-ID: 44510d9e1656fbc52721e7ceb41033359576f2a7
Gitweb: https://git.kernel.org/tip/44510d9e1656fbc52721e7ceb41033359576f2a7
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Mon, 29 Jan 2018 22:00:39 -0600
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 30 Jan 2018 07:55:04 +0100
objtool: Improve retpoline alternative handling
Currently objtool requires all retpolines to be:
a) patched in with alternatives; and
b) annotated with ANNOTATE_NOSPEC_ALTERNATIVE.
If you forget to do both of the above, objtool segfaults trying to
dereference a NULL 'insn->call_dest' pointer.
Avoid that situation and print a more helpful error message:
quirks.o: warning: objtool: efi_delete_dummy_variable()+0x99: unsupported intra-function call
quirks.o: warning: objtool: If this is a retpoline, please patch it in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE.
Future improvements can be made to make objtool smarter with respect to
retpolines, but this is a good incremental improvement for now.
Reported-and-tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/819e50b6d9c2e1a22e34c1a636c0b2057cc8c6e5.1517284349.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/objtool/check.c | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index f40d46e..bc3490d 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -543,18 +543,14 @@ static int add_call_destinations(struct objtool_file *file)
dest_off = insn->offset + insn->len + insn->immediate;
insn->call_dest = find_symbol_by_offset(insn->sec,
dest_off);
- /*
- * FIXME: Thanks to retpolines, it's now considered
- * normal for a function to call within itself. So
- * disable this warning for now.
- */
-#if 0
- if (!insn->call_dest) {
- WARN_FUNC("can't find call dest symbol at offset 0x%lx",
- insn->sec, insn->offset, dest_off);
+
+ if (!insn->call_dest && !insn->ignore) {
+ WARN_FUNC("unsupported intra-function call",
+ insn->sec, insn->offset);
+ WARN("If this is a retpoline, please patch it in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE.");
return -1;
}
-#endif
+
} else if (rela->sym->type == STT_SECTION) {
insn->call_dest = find_symbol_by_offset(rela->sym->sec,
rela->addend+4);
@@ -648,6 +644,8 @@ static int handle_group_alt(struct objtool_file *file,
last_new_insn = insn;
+ insn->ignore = orig_insn->ignore_alts;
+
if (insn->type != INSN_JUMP_CONDITIONAL &&
insn->type != INSN_JUMP_UNCONDITIONAL)
continue;
@@ -729,10 +727,6 @@ static int add_special_section_alts(struct objtool_file *file)
goto out;
}
- /* Ignore retpoline alternatives. */
- if (orig_insn->ignore_alts)
- continue;
-
new_insn = NULL;
if (!special_alt->group || special_alt->new_len) {
new_insn = find_insn(file, special_alt->new_sec,
@@ -1089,11 +1083,11 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
- ret = add_call_destinations(file);
+ ret = add_special_section_alts(file);
if (ret)
return ret;
- ret = add_special_section_alts(file);
+ ret = add_call_destinations(file);
if (ret)
return ret;
@@ -1720,10 +1714,12 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
insn->visited = true;
- list_for_each_entry(alt, &insn->alts, list) {
- ret = validate_branch(file, alt->insn, state);
- if (ret)
- return 1;
+ if (!insn->ignore_alts) {
+ list_for_each_entry(alt, &insn->alts, list) {
+ ret = validate_branch(file, alt->insn, state);
+ if (ret)
+ return 1;
+ }
}
switch (insn->type) {
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [tip:x86/pti] objtool: Add support for alternatives at the end of a section
2018-01-30 4:00 ` [PATCH 2/4] objtool: Add support for alternatives at the end of a section Josh Poimboeuf
@ 2018-01-30 8:46 ` tip-bot for Josh Poimboeuf
2018-01-30 14:13 ` tip-bot for Josh Poimboeuf
1 sibling, 0 replies; 15+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2018-01-30 8:46 UTC (permalink / raw)
To: linux-tip-commits
Cc: tglx, luto, gregkh, hpa, jgross, linux, linux-kernel, dwmw2,
torvalds, peterz, bp, jpoimboe, dave.hansen, mingo
Commit-ID: b18cbc614b4ddca4019ecd2e6663d54bd495d413
Gitweb: https://git.kernel.org/tip/b18cbc614b4ddca4019ecd2e6663d54bd495d413
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Mon, 29 Jan 2018 22:00:40 -0600
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 30 Jan 2018 07:55:05 +0100
objtool: Add support for alternatives at the end of a section
Now that the previous patch gave objtool the ability to read retpoline
alternatives, it shows a new warning:
arch/x86/entry/entry_64.o: warning: objtool: .entry_trampoline: don't know how to handle alternatives at end of section
This is due to the JMP_NOSPEC in entry_SYSCALL_64_trampoline().
Previously, objtool ignored this situation because it wasn't needed, and
it would have required a bit of extra code. Now that this case exists,
add proper support for it.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/2a30a3c2158af47d891a76e69bb1ef347e0443fd.1517284349.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/objtool/check.c | 53 ++++++++++++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 22 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index bc3490d..9cd028a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -594,7 +594,7 @@ static int handle_group_alt(struct objtool_file *file,
struct instruction *orig_insn,
struct instruction **new_insn)
{
- struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump;
+ struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump = NULL;
unsigned long dest_off;
last_orig_insn = NULL;
@@ -610,28 +610,30 @@ static int handle_group_alt(struct objtool_file *file,
last_orig_insn = insn;
}
- if (!next_insn_same_sec(file, last_orig_insn)) {
- WARN("%s: don't know how to handle alternatives at end of section",
- special_alt->orig_sec->name);
- return -1;
- }
-
- fake_jump = malloc(sizeof(*fake_jump));
- if (!fake_jump) {
- WARN("malloc failed");
- return -1;
+ if (next_insn_same_sec(file, last_orig_insn)) {
+ fake_jump = malloc(sizeof(*fake_jump));
+ if (!fake_jump) {
+ WARN("malloc failed");
+ return -1;
+ }
+ memset(fake_jump, 0, sizeof(*fake_jump));
+ INIT_LIST_HEAD(&fake_jump->alts);
+ clear_insn_state(&fake_jump->state);
+
+ fake_jump->sec = special_alt->new_sec;
+ fake_jump->offset = -1;
+ fake_jump->type = INSN_JUMP_UNCONDITIONAL;
+ fake_jump->jump_dest = list_next_entry(last_orig_insn, list);
+ fake_jump->ignore = true;
}
- memset(fake_jump, 0, sizeof(*fake_jump));
- INIT_LIST_HEAD(&fake_jump->alts);
- clear_insn_state(&fake_jump->state);
-
- fake_jump->sec = special_alt->new_sec;
- fake_jump->offset = -1;
- fake_jump->type = INSN_JUMP_UNCONDITIONAL;
- fake_jump->jump_dest = list_next_entry(last_orig_insn, list);
- fake_jump->ignore = true;
if (!special_alt->new_len) {
+ if (!fake_jump) {
+ WARN("%s: empty alternative at end of section",
+ special_alt->orig_sec->name);
+ return -1;
+ }
+
*new_insn = fake_jump;
return 0;
}
@@ -654,8 +656,14 @@ static int handle_group_alt(struct objtool_file *file,
continue;
dest_off = insn->offset + insn->len + insn->immediate;
- if (dest_off == special_alt->new_off + special_alt->new_len)
+ if (dest_off == special_alt->new_off + special_alt->new_len) {
+ if (!fake_jump) {
+ WARN("%s: alternative jump to end of section",
+ special_alt->orig_sec->name);
+ return -1;
+ }
insn->jump_dest = fake_jump;
+ }
if (!insn->jump_dest) {
WARN_FUNC("can't find alternative jump destination",
@@ -670,7 +678,8 @@ static int handle_group_alt(struct objtool_file *file,
return -1;
}
- list_add(&fake_jump->list, &last_new_insn->list);
+ if (fake_jump)
+ list_add(&fake_jump->list, &last_new_insn->list);
return 0;
}
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [tip:x86/pti] objtool: Warn on stripped section symbol
2018-01-30 4:00 ` [PATCH 3/4] objtool: Warn on stripped section symbol Josh Poimboeuf
@ 2018-01-30 8:47 ` tip-bot for Josh Poimboeuf
2018-01-30 14:13 ` tip-bot for Josh Poimboeuf
1 sibling, 0 replies; 15+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2018-01-30 8:47 UTC (permalink / raw)
To: linux-tip-commits
Cc: luto, peterz, linux, dwmw2, hpa, gregkh, bp, tglx, linux-kernel,
mingo, dave.hansen, jgross, torvalds, jpoimboe
Commit-ID: 2e9490ba5830a60a18a359192e938b2ad1710120
Gitweb: https://git.kernel.org/tip/2e9490ba5830a60a18a359192e938b2ad1710120
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Mon, 29 Jan 2018 22:00:41 -0600
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 30 Jan 2018 07:55:05 +0100
objtool: Warn on stripped section symbol
With the following fix:
2a0098d70640 ("objtool: Fix seg fault with gold linker")
... a seg fault was avoided, but the original seg fault condition in
objtool wasn't fixed. Replace the seg fault with an error message.
Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/dc4585a70d6b975c99fc51d1957ccdde7bd52f3a.1517284349.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/objtool/orc_gen.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
index e5ca314..e2c3b4b 100644
--- a/tools/objtool/orc_gen.c
+++ b/tools/objtool/orc_gen.c
@@ -98,6 +98,11 @@ static int create_orc_entry(struct section *u_sec, struct section *ip_relasec,
struct orc_entry *orc;
struct rela *rela;
+ if (!insn_sec->sym) {
+ WARN("missing symbol for section %s", insn_sec->name);
+ return -1;
+ }
+
/* populate ORC data */
orc = (struct orc_entry *)u_sec->data->d_buf + idx;
memcpy(orc, o, sizeof(*orc));
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [tip:x86/pti] objtool: Don't print '.tmp_' prefix for .o files when CONFIG_MODVERSIONS=y
2018-01-30 4:00 ` [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files Josh Poimboeuf
@ 2018-01-30 8:47 ` tip-bot for Josh Poimboeuf
2018-01-30 9:58 ` [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files Peter Zijlstra
1 sibling, 0 replies; 15+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2018-01-30 8:47 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux, jgross, hpa, peterz, dwmw2, gregkh, torvalds, jpoimboe,
tglx, bp, luto, linux-kernel, mingo, dave.hansen
Commit-ID: dfcb8dae5d28b7cf259b367ed9ccbc1296284e0d
Gitweb: https://git.kernel.org/tip/dfcb8dae5d28b7cf259b367ed9ccbc1296284e0d
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Mon, 29 Jan 2018 22:00:42 -0600
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 30 Jan 2018 07:55:05 +0100
objtool: Don't print '.tmp_' prefix for .o files when CONFIG_MODVERSIONS=y
With the following commit:
2a0098d70640 ("objtool: Fix seg fault with gold linker")
... objtool warnings started showing the modversions '.tmp_' prefix in
the .o file name, like:
arch/x86/mm/.tmp_mem_encrypt_boot.o: warning: objtool: sme_encrypt_execute()+0x48: indirect call found in RETPOLINE build
The prefix is confusing. Remove it from the printed 'objname' variable.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 2a0098d70640 ("objtool: Fix seg fault with gold linker")
Link: http://lkml.kernel.org/r/3788b5aec1c279184b78cdbd8b520903c0fb8a80.1517284349.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/objtool/check.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 9cd028a..d45ab4d 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1978,6 +1978,25 @@ static void cleanup(struct objtool_file *file)
elf_close(file->elf);
}
+/*
+ * With CONFIG_MODVERSIONS=y, the object name has '.tmp_' prepended to it.
+ * After the file has been opened, remove the prefix so warnings will look
+ * sensible.
+ */
+static void fix_objname(void)
+{
+ char *s;
+
+ s = strstr(objname, ".tmp_");
+ if (!s)
+ return;
+
+ for (; s[5]; s++)
+ s[0] = s[5];
+
+ s[0] = 0;
+}
+
int check(const char *_objname, bool _no_fp, bool no_unreachable, bool orc)
{
struct objtool_file file;
@@ -1990,6 +2009,8 @@ int check(const char *_objname, bool _no_fp, bool no_unreachable, bool orc)
if (!file.elf)
return 1;
+ fix_objname();
+
INIT_LIST_HEAD(&file.insn_list);
hash_init(file.insn_hash);
file.whitelist = find_section_by_name(file.elf, ".discard.func_stack_frame_non_standard");
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files
2018-01-30 4:00 ` [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files Josh Poimboeuf
2018-01-30 8:47 ` [tip:x86/pti] objtool: Don't print '.tmp_' prefix for .o files when CONFIG_MODVERSIONS=y tip-bot for Josh Poimboeuf
@ 2018-01-30 9:58 ` Peter Zijlstra
2018-01-30 15:53 ` Josh Poimboeuf
1 sibling, 1 reply; 15+ messages in thread
From: Peter Zijlstra @ 2018-01-30 9:58 UTC (permalink / raw)
To: Josh Poimboeuf
Cc: x86, linux-kernel, Ingo Molnar, David Woodhouse, Guenter Roeck
On Mon, Jan 29, 2018 at 10:00:42PM -0600, Josh Poimboeuf wrote:
> With the following commit:
>
> 2a0098d70640 ("objtool: Fix seg fault with gold linker")
>
> ... objtool warnings started showing the modversions '.tmp_' prefix in
> the .o file name, like:
>
> arch/x86/mm/.tmp_mem_encrypt_boot.o: warning: objtool: sme_encrypt_execute()+0x48: indirect call found in RETPOLINE build
>
> The prefix is confusing. Remove it from the printed 'objname' variable.
This patch actually tripped me up today. Turns out I have both:
build/kernel/sched/core.o
build/kernel/sched/.tmp_core.o
and ended up staring at the wrong file and going WTF because the offsets
didn't match.
I much prefer the actual real filename printed. Yes the .tmp_ crud is
weird, but at least its the real file.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [tip:x86/pti] objtool: Improve retpoline alternative handling
2018-01-30 4:00 ` [PATCH 1/4] objtool: Improve retpoline alternative handling Josh Poimboeuf
2018-01-30 8:46 ` [tip:x86/pti] " tip-bot for Josh Poimboeuf
@ 2018-01-30 14:12 ` tip-bot for Josh Poimboeuf
1 sibling, 0 replies; 15+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2018-01-30 14:12 UTC (permalink / raw)
To: linux-tip-commits
Cc: peterz, gregkh, linux, torvalds, jpoimboe, linux-kernel, luto,
jgross, tglx, hpa, dwmw2, bp, mingo, dave.hansen
Commit-ID: a845c7cf4b4cb5e9e3b2823867892b27646f3a98
Gitweb: https://git.kernel.org/tip/a845c7cf4b4cb5e9e3b2823867892b27646f3a98
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Mon, 29 Jan 2018 22:00:39 -0600
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 30 Jan 2018 15:09:14 +0100
objtool: Improve retpoline alternative handling
Currently objtool requires all retpolines to be:
a) patched in with alternatives; and
b) annotated with ANNOTATE_NOSPEC_ALTERNATIVE.
If you forget to do both of the above, objtool segfaults trying to
dereference a NULL 'insn->call_dest' pointer.
Avoid that situation and print a more helpful error message:
quirks.o: warning: objtool: efi_delete_dummy_variable()+0x99: unsupported intra-function call
quirks.o: warning: objtool: If this is a retpoline, please patch it in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE.
Future improvements can be made to make objtool smarter with respect to
retpolines, but this is a good incremental improvement for now.
Reported-and-tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/819e50b6d9c2e1a22e34c1a636c0b2057cc8c6e5.1517284349.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/objtool/check.c | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index f40d46e..bc3490d 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -543,18 +543,14 @@ static int add_call_destinations(struct objtool_file *file)
dest_off = insn->offset + insn->len + insn->immediate;
insn->call_dest = find_symbol_by_offset(insn->sec,
dest_off);
- /*
- * FIXME: Thanks to retpolines, it's now considered
- * normal for a function to call within itself. So
- * disable this warning for now.
- */
-#if 0
- if (!insn->call_dest) {
- WARN_FUNC("can't find call dest symbol at offset 0x%lx",
- insn->sec, insn->offset, dest_off);
+
+ if (!insn->call_dest && !insn->ignore) {
+ WARN_FUNC("unsupported intra-function call",
+ insn->sec, insn->offset);
+ WARN("If this is a retpoline, please patch it in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE.");
return -1;
}
-#endif
+
} else if (rela->sym->type == STT_SECTION) {
insn->call_dest = find_symbol_by_offset(rela->sym->sec,
rela->addend+4);
@@ -648,6 +644,8 @@ static int handle_group_alt(struct objtool_file *file,
last_new_insn = insn;
+ insn->ignore = orig_insn->ignore_alts;
+
if (insn->type != INSN_JUMP_CONDITIONAL &&
insn->type != INSN_JUMP_UNCONDITIONAL)
continue;
@@ -729,10 +727,6 @@ static int add_special_section_alts(struct objtool_file *file)
goto out;
}
- /* Ignore retpoline alternatives. */
- if (orig_insn->ignore_alts)
- continue;
-
new_insn = NULL;
if (!special_alt->group || special_alt->new_len) {
new_insn = find_insn(file, special_alt->new_sec,
@@ -1089,11 +1083,11 @@ static int decode_sections(struct objtool_file *file)
if (ret)
return ret;
- ret = add_call_destinations(file);
+ ret = add_special_section_alts(file);
if (ret)
return ret;
- ret = add_special_section_alts(file);
+ ret = add_call_destinations(file);
if (ret)
return ret;
@@ -1720,10 +1714,12 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
insn->visited = true;
- list_for_each_entry(alt, &insn->alts, list) {
- ret = validate_branch(file, alt->insn, state);
- if (ret)
- return 1;
+ if (!insn->ignore_alts) {
+ list_for_each_entry(alt, &insn->alts, list) {
+ ret = validate_branch(file, alt->insn, state);
+ if (ret)
+ return 1;
+ }
}
switch (insn->type) {
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [tip:x86/pti] objtool: Add support for alternatives at the end of a section
2018-01-30 4:00 ` [PATCH 2/4] objtool: Add support for alternatives at the end of a section Josh Poimboeuf
2018-01-30 8:46 ` [tip:x86/pti] " tip-bot for Josh Poimboeuf
@ 2018-01-30 14:13 ` tip-bot for Josh Poimboeuf
1 sibling, 0 replies; 15+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2018-01-30 14:13 UTC (permalink / raw)
To: linux-tip-commits
Cc: bp, gregkh, jpoimboe, linux, linux-kernel, dwmw2, jgross,
torvalds, luto, tglx, hpa, mingo, dave.hansen, peterz
Commit-ID: 17bc33914bcc98ba3c6b426fd1c49587a25c0597
Gitweb: https://git.kernel.org/tip/17bc33914bcc98ba3c6b426fd1c49587a25c0597
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Mon, 29 Jan 2018 22:00:40 -0600
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 30 Jan 2018 15:09:17 +0100
objtool: Add support for alternatives at the end of a section
Now that the previous patch gave objtool the ability to read retpoline
alternatives, it shows a new warning:
arch/x86/entry/entry_64.o: warning: objtool: .entry_trampoline: don't know how to handle alternatives at end of section
This is due to the JMP_NOSPEC in entry_SYSCALL_64_trampoline().
Previously, objtool ignored this situation because it wasn't needed, and
it would have required a bit of extra code. Now that this case exists,
add proper support for it.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/2a30a3c2158af47d891a76e69bb1ef347e0443fd.1517284349.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/objtool/check.c | 53 ++++++++++++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 22 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index bc3490d..9cd028a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -594,7 +594,7 @@ static int handle_group_alt(struct objtool_file *file,
struct instruction *orig_insn,
struct instruction **new_insn)
{
- struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump;
+ struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump = NULL;
unsigned long dest_off;
last_orig_insn = NULL;
@@ -610,28 +610,30 @@ static int handle_group_alt(struct objtool_file *file,
last_orig_insn = insn;
}
- if (!next_insn_same_sec(file, last_orig_insn)) {
- WARN("%s: don't know how to handle alternatives at end of section",
- special_alt->orig_sec->name);
- return -1;
- }
-
- fake_jump = malloc(sizeof(*fake_jump));
- if (!fake_jump) {
- WARN("malloc failed");
- return -1;
+ if (next_insn_same_sec(file, last_orig_insn)) {
+ fake_jump = malloc(sizeof(*fake_jump));
+ if (!fake_jump) {
+ WARN("malloc failed");
+ return -1;
+ }
+ memset(fake_jump, 0, sizeof(*fake_jump));
+ INIT_LIST_HEAD(&fake_jump->alts);
+ clear_insn_state(&fake_jump->state);
+
+ fake_jump->sec = special_alt->new_sec;
+ fake_jump->offset = -1;
+ fake_jump->type = INSN_JUMP_UNCONDITIONAL;
+ fake_jump->jump_dest = list_next_entry(last_orig_insn, list);
+ fake_jump->ignore = true;
}
- memset(fake_jump, 0, sizeof(*fake_jump));
- INIT_LIST_HEAD(&fake_jump->alts);
- clear_insn_state(&fake_jump->state);
-
- fake_jump->sec = special_alt->new_sec;
- fake_jump->offset = -1;
- fake_jump->type = INSN_JUMP_UNCONDITIONAL;
- fake_jump->jump_dest = list_next_entry(last_orig_insn, list);
- fake_jump->ignore = true;
if (!special_alt->new_len) {
+ if (!fake_jump) {
+ WARN("%s: empty alternative at end of section",
+ special_alt->orig_sec->name);
+ return -1;
+ }
+
*new_insn = fake_jump;
return 0;
}
@@ -654,8 +656,14 @@ static int handle_group_alt(struct objtool_file *file,
continue;
dest_off = insn->offset + insn->len + insn->immediate;
- if (dest_off == special_alt->new_off + special_alt->new_len)
+ if (dest_off == special_alt->new_off + special_alt->new_len) {
+ if (!fake_jump) {
+ WARN("%s: alternative jump to end of section",
+ special_alt->orig_sec->name);
+ return -1;
+ }
insn->jump_dest = fake_jump;
+ }
if (!insn->jump_dest) {
WARN_FUNC("can't find alternative jump destination",
@@ -670,7 +678,8 @@ static int handle_group_alt(struct objtool_file *file,
return -1;
}
- list_add(&fake_jump->list, &last_new_insn->list);
+ if (fake_jump)
+ list_add(&fake_jump->list, &last_new_insn->list);
return 0;
}
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [tip:x86/pti] objtool: Warn on stripped section symbol
2018-01-30 4:00 ` [PATCH 3/4] objtool: Warn on stripped section symbol Josh Poimboeuf
2018-01-30 8:47 ` [tip:x86/pti] " tip-bot for Josh Poimboeuf
@ 2018-01-30 14:13 ` tip-bot for Josh Poimboeuf
1 sibling, 0 replies; 15+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2018-01-30 14:13 UTC (permalink / raw)
To: linux-tip-commits
Cc: jgross, jpoimboe, dave.hansen, tglx, hpa, linux, bp, dwmw2,
torvalds, gregkh, linux-kernel, luto, peterz, mingo
Commit-ID: 830c1e3d16b2c1733cd1ec9c8f4d47a398ae31bc
Gitweb: https://git.kernel.org/tip/830c1e3d16b2c1733cd1ec9c8f4d47a398ae31bc
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Mon, 29 Jan 2018 22:00:41 -0600
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 30 Jan 2018 15:09:23 +0100
objtool: Warn on stripped section symbol
With the following fix:
2a0098d70640 ("objtool: Fix seg fault with gold linker")
... a seg fault was avoided, but the original seg fault condition in
objtool wasn't fixed. Replace the seg fault with an error message.
Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/dc4585a70d6b975c99fc51d1957ccdde7bd52f3a.1517284349.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/objtool/orc_gen.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
index e61fe70..18384d9 100644
--- a/tools/objtool/orc_gen.c
+++ b/tools/objtool/orc_gen.c
@@ -98,6 +98,11 @@ static int create_orc_entry(struct section *u_sec, struct section *ip_relasec,
struct orc_entry *orc;
struct rela *rela;
+ if (!insn_sec->sym) {
+ WARN("missing symbol for section %s", insn_sec->name);
+ return -1;
+ }
+
/* populate ORC data */
orc = (struct orc_entry *)u_sec->data->d_buf + idx;
memcpy(orc, o, sizeof(*orc));
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files
2018-01-30 9:58 ` [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files Peter Zijlstra
@ 2018-01-30 15:53 ` Josh Poimboeuf
2018-01-31 6:17 ` Ingo Molnar
0 siblings, 1 reply; 15+ messages in thread
From: Josh Poimboeuf @ 2018-01-30 15:53 UTC (permalink / raw)
To: Peter Zijlstra
Cc: x86, linux-kernel, Ingo Molnar, David Woodhouse, Guenter Roeck
On Tue, Jan 30, 2018 at 10:58:31AM +0100, Peter Zijlstra wrote:
> On Mon, Jan 29, 2018 at 10:00:42PM -0600, Josh Poimboeuf wrote:
> > With the following commit:
> >
> > 2a0098d70640 ("objtool: Fix seg fault with gold linker")
> >
> > ... objtool warnings started showing the modversions '.tmp_' prefix in
> > the .o file name, like:
> >
> > arch/x86/mm/.tmp_mem_encrypt_boot.o: warning: objtool: sme_encrypt_execute()+0x48: indirect call found in RETPOLINE build
> >
> > The prefix is confusing. Remove it from the printed 'objname' variable.
>
> This patch actually tripped me up today. Turns out I have both:
>
> build/kernel/sched/core.o
> build/kernel/sched/.tmp_core.o
>
> and ended up staring at the wrong file and going WTF because the offsets
> didn't match.
>
> I much prefer the actual real filename printed. Yes the .tmp_ crud is
> weird, but at least its the real file.
Good point, sorry for tripping you up there. I see it's been removed
from -tip now. We should look at changing how the modversions stuff
does its renaming so this will be less confusing.
--
Josh
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files
2018-01-30 15:53 ` Josh Poimboeuf
@ 2018-01-31 6:17 ` Ingo Molnar
0 siblings, 0 replies; 15+ messages in thread
From: Ingo Molnar @ 2018-01-31 6:17 UTC (permalink / raw)
To: Josh Poimboeuf
Cc: Peter Zijlstra, x86, linux-kernel, David Woodhouse, Guenter Roeck
* Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> On Tue, Jan 30, 2018 at 10:58:31AM +0100, Peter Zijlstra wrote:
> > On Mon, Jan 29, 2018 at 10:00:42PM -0600, Josh Poimboeuf wrote:
> > > With the following commit:
> > >
> > > 2a0098d70640 ("objtool: Fix seg fault with gold linker")
> > >
> > > ... objtool warnings started showing the modversions '.tmp_' prefix in
> > > the .o file name, like:
> > >
> > > arch/x86/mm/.tmp_mem_encrypt_boot.o: warning: objtool: sme_encrypt_execute()+0x48: indirect call found in RETPOLINE build
> > >
> > > The prefix is confusing. Remove it from the printed 'objname' variable.
> >
> > This patch actually tripped me up today. Turns out I have both:
> >
> > build/kernel/sched/core.o
> > build/kernel/sched/.tmp_core.o
> >
> > and ended up staring at the wrong file and going WTF because the offsets
> > didn't match.
> >
> > I much prefer the actual real filename printed. Yes the .tmp_ crud is
> > weird, but at least its the real file.
>
> Good point, sorry for tripping you up there. I see it's been removed
> from -tip now. [...]
Yeah, and we had to rebase to a later kernel anyway so it was easy to remove it
for now.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2018-01-31 6:17 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-30 4:00 [PATCH 0/4] objtool: seg fault fixes and retpoline improvements Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 1/4] objtool: Improve retpoline alternative handling Josh Poimboeuf
2018-01-30 8:46 ` [tip:x86/pti] " tip-bot for Josh Poimboeuf
2018-01-30 14:12 ` tip-bot for Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 2/4] objtool: Add support for alternatives at the end of a section Josh Poimboeuf
2018-01-30 8:46 ` [tip:x86/pti] " tip-bot for Josh Poimboeuf
2018-01-30 14:13 ` tip-bot for Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 3/4] objtool: Warn on stripped section symbol Josh Poimboeuf
2018-01-30 8:47 ` [tip:x86/pti] " tip-bot for Josh Poimboeuf
2018-01-30 14:13 ` tip-bot for Josh Poimboeuf
2018-01-30 4:00 ` [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files Josh Poimboeuf
2018-01-30 8:47 ` [tip:x86/pti] objtool: Don't print '.tmp_' prefix for .o files when CONFIG_MODVERSIONS=y tip-bot for Josh Poimboeuf
2018-01-30 9:58 ` [PATCH 4/4] objtool: Don't print '.tmp_' prefix for .o files Peter Zijlstra
2018-01-30 15:53 ` Josh Poimboeuf
2018-01-31 6:17 ` Ingo Molnar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.