Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lkdtm: Fix content of section containing lkdtm_rodata_do_nothing()

On a kernel without CONFIG_STRICT_KERNEL_RWX, running EXEC_RODATA
test leads to "Illegal instruction" failure.

Looking at the content of rodata_objcopy.o, we see that the
function content zeroes only:

Disassembly of section .rodata:

0000000000000000 <.lkdtm_rodata_do_nothing>:
0: 00 00 00 00 .long 0x0

Add the contents flag in order to keep the content of the section
while renaming it.

Disassembly of section .rodata:

0000000000000000 <.lkdtm_rodata_do_nothing>:
0: 4e 80 00 20 blr

Fixes: e9e08a07385e ("lkdtm: support llvm-objcopy")
Cc: stable@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/8900731fbc05fb8b0de18af7133a8fc07c3c53a1.1633712176.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Kees Cook
bc93a22a 026c6fa1

+1 -1
+1 -1
drivers/misc/lkdtm/Makefile
··· 20 20 21 21 OBJCOPYFLAGS := 22 22 OBJCOPYFLAGS_rodata_objcopy.o := \ 23 - --rename-section .noinstr.text=.rodata,alloc,readonly,load 23 + --rename-section .noinstr.text=.rodata,alloc,readonly,load,contents 24 24 targets += rodata.o rodata_objcopy.o 25 25 $(obj)/rodata_objcopy.o: $(obj)/rodata.o FORCE 26 26 $(call if_changed,objcopy)