[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <168629686249.404.5579713530746693171.tip-bot2@tip-bot2>
Date: Fri, 09 Jun 2023 07:47:42 -0000
From: "tip-bot2 for Peter Zijlstra" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: kernel test robot <lkp@...el.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Kees Cook <keescook@...omium.org>,
Josh Poimboeuf <jpoimboe@...nel.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: objtool/core] lkdtm: Avoid objtool/ibt warning
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 4a03aa34432abe0703abf232f31fc5e2ed8256f6
Gitweb: https://git.kernel.org/tip/4a03aa34432abe0703abf232f31fc5e2ed8256f6
Author: Peter Zijlstra <peterz@...radead.org>
AuthorDate: Mon, 14 Nov 2022 16:23:45 +01:00
Committer: Josh Poimboeuf <jpoimboe@...nel.org>
CommitterDate: Wed, 07 Jun 2023 09:27:11 -07:00
lkdtm: Avoid objtool/ibt warning
For certain configs objtool will complain like:
vmlinux.o: warning: objtool: lkdtm_UNSET_SMEP+0x1c3: relocation to !ENDBR: native_write_cr4+0x41
What happens is that GCC optimizes the loop:
insn = (unsigned char *)native_write_cr4;
for (i = 0; i < MOV_CR4_DEPTH; i++)
to read something like:
for (insn = (unsigned char *)native_write_cr4;
insn < (unsigned char *)native_write_cr4 + MOV_CR4_DEPTH;
insn++)
Which then obviously generates the text reference
native_write_cr4+041. Since none of this is a fast path, simply
confuse GCC enough to inhibit this optimization.
Reported-by: kernel test robot <lkp@...el.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Acked-by: Kees Cook <keescook@...omium.org>
Link: https://lore.kernel.org/r/Y3JdgbXRV0MNZ+9h@hirez.programming.kicks-ass.net
Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
---
drivers/misc/lkdtm/bugs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/misc/lkdtm/bugs.c b/drivers/misc/lkdtm/bugs.c
index 48821f4..92110cb 100644
--- a/drivers/misc/lkdtm/bugs.c
+++ b/drivers/misc/lkdtm/bugs.c
@@ -487,6 +487,7 @@ static void lkdtm_UNSET_SMEP(void)
* the cr4 writing instruction.
*/
insn = (unsigned char *)native_write_cr4;
+ OPTIMIZER_HIDE_VAR(insn);
for (i = 0; i < MOV_CR4_DEPTH; i++) {
/* mov %rdi, %cr4 */
if (insn[i] == 0x0f && insn[i+1] == 0x22 && insn[i+2] == 0xe7)
Powered by blists - more mailing lists