lkml.org 
[lkml]   [2020]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[tip: objtool/core] objtool: Clean instruction state before each function validation
The following commit has been merged into the objtool/core branch of tip:

Commit-ID: bb44b5247111c1bcd64e2eb9ad4e09c10c52ca92
Gitweb: https://git.kernel.org/tip/bb44b5247111c1bcd64e2eb9ad4e09c10c52ca92
Author: Julien Thierry <jthierry@redhat.com>
AuthorDate: Fri, 27 Mar 2020 15:28:40
Committer: Josh Poimboeuf <jpoimboe@redhat.com>
CommitterDate: Tue, 14 Apr 2020 10:39:24 -05:00

objtool: Clean instruction state before each function validation

When a function fails its validation, it might leave a stale state
that will be used for the validation of other functions. That would
cause false warnings on potentially valid functions.

Reset the instruction state before the validation of each individual
function.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
tools/objtool/check.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index ed01059..93ef14a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2429,13 +2429,6 @@ static int validate_section(struct objtool_file *file, struct section *sec)
struct insn_state state;
int ret, warnings = 0;

- clear_insn_state(&state);
-
- state.cfa = initial_func_cfi.cfa;
- memcpy(&state.regs, &initial_func_cfi.regs,
- CFI_NUM_REGS * sizeof(struct cfi_reg));
- state.stack_size = initial_func_cfi.cfa.offset;
-
list_for_each_entry(func, &sec->symbol_list, list) {
if (func->type != STT_FUNC)
continue;
@@ -2453,6 +2446,12 @@ static int validate_section(struct objtool_file *file, struct section *sec)
if (!insn || insn->ignore || insn->visited)
continue;

+ clear_insn_state(&state);
+ state.cfa = initial_func_cfi.cfa;
+ memcpy(&state.regs, &initial_func_cfi.regs,
+ CFI_NUM_REGS * sizeof(struct cfi_reg));
+ state.stack_size = initial_func_cfi.cfa.offset;
+
state.uaccess = func->uaccess_safe;

ret = validate_branch(file, func, insn, state);
\
 
 \ /
  Last update: 2020-04-23 00:25    [W:0.041 / U:1.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site