[tip: objtool/urgent] objtool: Always fail on fatal errors

From: tip-bot2 for Josh Poimboeuf
Date: Tue Apr 01 2025 - 03:16:06 EST


The following commit has been merged into the objtool/urgent branch of tip:

Commit-ID: 0b10177114d1e434af850b377cf5e6620dd1d525
Gitweb: https://git.kernel.org/tip/0b10177114d1e434af850b377cf5e6620dd1d525
Author: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
AuthorDate: Mon, 31 Mar 2025 21:26:40 -07:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Tue, 01 Apr 2025 09:07:13 +02:00

objtool: Always fail on fatal errors

Objtool writes several object annotations which are used to enable
critical kernel runtime functionalities like static calls and
retpoline/rethunk patching.

In the rare case where it fails to read or write an object, the
annotations don't get written, causing runtime code patching to fail and
code to become corrupted.

Due to the catastrophic nature of such warnings, convert them to errors
which fail the build regardless of CONFIG_OBJTOOL_WERROR.

Reported-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@xxxxxxxxx>
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Link: https://lore.kernel.org/r/7d35684ca61eac56eb2424f300ca43c5d257b170.1743481539.git.jpoimboe@xxxxxxxxxx
Closes: https://lore.kernel.org/SJ1PR11MB61295789E25C2F5197EFF2F6B9A72@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
---
tools/objtool/check.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index c8b3c8e..cde6699 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4753,6 +4753,9 @@ out:
if (!ret && !warnings)
return 0;

+ if (opts.werror && warnings)
+ ret = 1;
+
if (opts.verbose) {
if (opts.werror && warnings)
WARN("%d warning(s) upgraded to errors", warnings);
@@ -4760,15 +4763,5 @@ out:
disas_warned_funcs(file);
}

- /*
- * CONFIG_OBJTOOL_WERROR upgrades all warnings (and errors) to actual
- * errors.
- *
- * Note that even fatal errors don't yet actually return an error
- * without CONFIG_OBJTOOL_WERROR. That will be fixed soon-ish.
- */
- if (opts.werror)
- return 1;
-
- return 0;
+ return ret;
}