lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 13 Apr 2022 16:19:38 -0700
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     x86@...nel.org
Cc:     Peter Zijlstra <peterz@...radead.org>,
        linux-kernel@...r.kernel.org, Miroslav Benes <mbenes@...e.cz>,
        Nick Desaulniers <ndesaulniers@...gle.com>
Subject: [PATCH 03/18] objtool: Add sec+offset to warnings

Change this:

  vmlinux.o: warning: objtool: fixup_exception()+0x2d1: unreachable instruction

to this:

  vmlinux.o: warning: objtool: fixup_exception()+0x2d1: .text+0x76c51: unreachable instruction

It's noisier, but it makes our lives considerably easier.

Make this new 'verbose' mode optional, which will come in handy soon.

Suggested-by: Nick Desaulniers <ndesaulniers@...gle.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
---
 tools/objtool/include/objtool/warn.h | 39 +++++++++++++---------------
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/objtool/warn.h
index dab0dda7c617..a4c6b52a58c9 100644
--- a/tools/objtool/include/objtool/warn.h
+++ b/tools/objtool/include/objtool/warn.h
@@ -15,12 +15,13 @@
 
 extern const char *objname;
 
-static inline char *offstr(struct section *sec, unsigned long offset)
+static inline char *offstr(struct section *sec, unsigned long offset,
+			   bool verbose)
 {
 	bool is_text = (sec->sh.sh_flags & SHF_EXECINSTR);
 	struct symbol *sym = NULL;
-	unsigned long name_off;
-	char *name, *str;
+	char *str;
+	int len;
 
 	if (is_text)
 		sym = find_func_containing(sec, offset);
@@ -28,20 +29,16 @@ static inline char *offstr(struct section *sec, unsigned long offset)
 		sym = find_symbol_containing(sec, offset);
 
 	if (sym) {
-		name = sym->name;
-		name_off = offset - sym->offset;
+		str = malloc(strlen(sym->name) + strlen(sec->name) + 40);
+		len = sprintf(str, "%s%s+0x%lx",
+			      sym->name, is_text ? "()" : "", offset - sym->offset);
+		if (verbose)
+			sprintf(str+len, ": %s+0x%lx", sec->name, offset);
 	} else {
-		name = sec->name;
-		name_off = offset;
+		str = malloc(strlen(sec->name) + 20);
+		sprintf(str, "%s+0x%lx", sec->name, offset);
 	}
 
-	str = malloc(strlen(name) + 20);
-
-	if (sym)
-		sprintf(str, "%s%s+0x%lx", name, is_text ? "()" : "", name_off);
-	else
-		sprintf(str, "%s+0x%lx", name, name_off);
-
 	return str;
 }
 
@@ -52,17 +49,17 @@ static inline char *offstr(struct section *sec, unsigned long offset)
 
 #define WARN_FUNC(format, sec, offset, ...)		\
 ({							\
-	char *_str = offstr(sec, offset);		\
+	char *_str = offstr(sec, offset, true);		\
 	WARN("%s: " format, _str, ##__VA_ARGS__);	\
 	free(_str);					\
 })
 
-#define BT_FUNC(format, insn, ...)			\
-({							\
-	struct instruction *_insn = (insn);		\
-	char *_str = offstr(_insn->sec, _insn->offset); \
-	WARN("  %s: " format, _str, ##__VA_ARGS__);	\
-	free(_str);					\
+#define BT_FUNC(format, insn, ...)				\
+({								\
+	struct instruction *_insn = (insn);			\
+	char *_str = offstr(_insn->sec, _insn->offset, true);	\
+	WARN("  %s: " format, _str, ##__VA_ARGS__);		\
+	free(_str);						\
 })
 
 #define WARN_ELF(format, ...)				\
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ