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: <4f22aa05702ca037630fa6c1f7fd54d13914a631.1679932620.git.jpoimboe@kernel.org>
Date:   Mon, 27 Mar 2023 09:00:48 -0700
From:   Josh Poimboeuf <jpoimboe@...nel.org>
To:     x86@...nel.org
Cc:     linux-kernel@...r.kernel.org, Peter Zijlstra <peterz@...radead.org>
Subject: [PATCH 5/5] objtool: Add "missing __noreturn" warning

Most "unreachable instruction" warnings these days seem to actually be
the result of a missing __noreturn annotation.  Add an explicit check
for that.

Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
---
 tools/objtool/Documentation/objtool.txt |  7 +++++++
 tools/objtool/check.c                   | 16 ++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt
index ec6f82fb414c..e04d16490c3b 100644
--- a/tools/objtool/Documentation/objtool.txt
+++ b/tools/objtool/Documentation/objtool.txt
@@ -423,6 +423,13 @@ the objtool maintainers.
    names and does not use module_init() / module_exit() macros to create
    them.
 
+13. file.o: warning: func(): missing __noreturn
+
+   Objtool has detected that the function doesn't return, but is missing
+   the __noreturn annotation.  NOTE: In addition to adding the
+   __noreturn annotation, the function name also needs to be added to
+   'global_noreturns' in tools/objtool/check.c.
+
 
 If the error doesn't seem to make sense, it could be a bug in objtool.
 Feel free to ask the objtool maintainer for help.
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 67a684225702..1ed3024af2b1 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4548,7 +4548,8 @@ static int validate_sls(struct objtool_file *file)
 
 static int validate_reachable_instructions(struct objtool_file *file)
 {
-	struct instruction *insn;
+	struct instruction *insn, *prev_insn;
+	struct symbol *call_dest;
 
 	if (file->ignore_unreachables)
 		return 0;
@@ -4561,8 +4562,19 @@ static int validate_reachable_instructions(struct objtool_file *file)
 			continue;
 		insn->sym->warned = 1;
 
+		prev_insn = prev_insn_same_sec(file, insn);
+		if (prev_insn)
+			call_dest = insn_call_dest(prev_insn);
+		if (prev_insn && prev_insn->dead_end && call_dest) {
+			if (call_dest->warned)
+				continue;
+			call_dest->warned = 1;
+
+			WARN("%s(): missing __noreturn", call_dest->name);
+			continue;
+		}
+
 		WARN_FUNC("unreachable instruction", insn->sec, insn->offset);
-		return 1;
 	}
 
 	return 0;
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ