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: <Y3JdgbXRV0MNZ+9h@hirez.programming.kicks-ass.net>
Date:   Mon, 14 Nov 2022 16:23:45 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     kernel test robot <lkp@...el.com>,
        Kees Cook <keescook@...omium.org>
Cc:     oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Josh Poimboeuf <jpoimboe@...hat.com>
Subject: [PATCH] lkdtm: Avoid objtool/ibt warning

On Mon, Nov 14, 2022 at 08:26:17PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   094226ad94f471a9f19e8f8e7140a09c2625abaa
> commit: 656d054e0a15ec327bd82801ccd58201e59f6896 jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
> date:   6 months ago
> config: x86_64-buildonly-randconfig-r001-20221114
> compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
> reproduce (this is a W=1 build):
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=656d054e0a15ec327bd82801ccd58201e59f6896
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout 656d054e0a15ec327bd82801ccd58201e59f6896
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash


> >> vmlinux.o: warning: objtool: lkdtm_UNSET_SMEP+0x1c3: relocation to !ENDBR: native_write_cr4+0x41

---
Subject: lkdtm: Avoid objtool/ibt warning
From: Peter Zijlstra <peterz@...radead.org>
Date: Mon Nov 14 16:17:50 CET 2022

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>
---
 drivers/misc/lkdtm/bugs.c |    1 +
 1 file changed, 1 insertion(+)

--- 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

Powered by Openwall GNU/*/Linux Powered by OpenVZ