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]
Message-Id: <217a005fe22f9d33f99fed499d6508af9f5cabd0.1679932620.git.jpoimboe@kernel.org>
Date:   Mon, 27 Mar 2023 09:00:44 -0700
From:   Josh Poimboeuf <jpoimboe@...nel.org>
To:     x86@...nel.org
Cc:     linux-kernel@...r.kernel.org, Peter Zijlstra <peterz@...radead.org>
Subject: [PATCH 1/5] objtool: Add '--verbose' option for disassembling affected functions

When a warning is associated with a function, add an option to
disassemble that function.

This makes it easier for reporters to submit the information needed to
diagnose objtool warnings.

Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
---
 tools/objtool/Documentation/objtool.txt |  5 ++++
 tools/objtool/builtin-check.c           |  1 +
 tools/objtool/include/objtool/builtin.h |  1 +
 tools/objtool/include/objtool/warn.h    | 38 +++++++++++++++++++++++++
 4 files changed, 45 insertions(+)

diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt
index 8e53fc6735ef..7c1a46af322f 100644
--- a/tools/objtool/Documentation/objtool.txt
+++ b/tools/objtool/Documentation/objtool.txt
@@ -244,6 +244,11 @@ To achieve the validation, objtool enforces the following rules:
 Objtool warnings
 ----------------
 
+NOTE: When requesting help with an objtool warning, please re-run the
+kernel build with `OBJTOOL_ARGS="--verbose" make <whatever>` and send
+the full warning output (including any function disassembly below the
+warning) to the objtool maintainers.
+
 For asm files, if you're getting an error which doesn't make sense,
 first make sure that the affected code follows the above rules.
 
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 7c175198d09f..b8de42f6778e 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -93,6 +93,7 @@ static const struct option check_options[] = {
 	OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachable instruction' warnings"),
 	OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses in warnings"),
 	OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"),
+	OPT_BOOLEAN('v', "verbose", &opts.verbose, "verbose warnings"),
 
 	OPT_END(),
 };
diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/include/objtool/builtin.h
index 2a108e648b7a..fcca6662c8b4 100644
--- a/tools/objtool/include/objtool/builtin.h
+++ b/tools/objtool/include/objtool/builtin.h
@@ -37,6 +37,7 @@ struct opts {
 	bool no_unreachable;
 	bool sec_address;
 	bool stats;
+	bool verbose;
 };
 
 extern struct opts opts;
diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/objtool/warn.h
index a3e79ae75f2e..b85aa440ee1f 100644
--- a/tools/objtool/include/objtool/warn.h
+++ b/tools/objtool/include/objtool/warn.h
@@ -11,6 +11,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <unistd.h>
 #include <objtool/builtin.h>
 #include <objtool/elf.h>
 
@@ -41,6 +42,41 @@ static inline char *offstr(struct section *sec, unsigned long offset)
 	return str;
 }
 
+static inline void objdump_func(struct section *sec, unsigned long offset)
+{
+	struct symbol *sym = find_func_containing(sec, offset);
+	const char *script_relative = "scripts/objdump-func";
+	bool is_text = (sec->sh.sh_flags & SHF_EXECINSTR);
+	char *cmd, *srctree, *script;
+
+	if (is_text)
+		sym = find_func_containing(sec, offset);
+	if (!sym)
+		sym = find_symbol_containing(sec, offset);
+	if (!sym)
+		return;
+
+	srctree = getenv("abs_srctree");
+	if (!srctree)
+		return;
+
+	script = malloc(strlen(srctree) + strlen(script_relative) + 2);
+	if (!script)
+		return;
+
+	sprintf(script, "%s/%s", srctree, script_relative);
+
+	if (access(script, X_OK))
+		return;
+
+	cmd = malloc(strlen(script) + strlen(objname) + strlen(sym->name) + 10);
+	if (!cmd)
+		return;
+
+	sprintf(cmd, "%s %s %s 1>&2", script, objname, sym->name);
+	system(cmd);
+}
+
 #define WARN(format, ...)				\
 	fprintf(stderr,					\
 		"%s: warning: objtool: " format "\n",	\
@@ -51,6 +87,8 @@ static inline char *offstr(struct section *sec, unsigned long offset)
 	char *_str = offstr(sec, offset);		\
 	WARN("%s: " format, _str, ##__VA_ARGS__);	\
 	free(_str);					\
+	if (opts.verbose)				\
+		objdump_func(sec, offset);		\
 })
 
 #define BT_FUNC(format, insn, ...)			\
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ