lkdtm: Disable CFI checking for perms functions
authorKees Cook <keescook@chromium.org>
Tue, 30 Apr 2024 23:49:57 +0000 (16:49 -0700)
committerKees Cook <keescook@chromium.org>
Wed, 1 May 2024 19:37:42 +0000 (12:37 -0700)
The EXEC_RODATA test plays a lot of tricks to live in the .rodata section,
and once again ran into objtool's (completely reasonable) assumptions
that executable code should live in an executable section. However, this
manifested only under CONFIG_CFI_CLANG=y, as one of the .cfi_sites was
pointing into the .rodata section.

Since we're testing non-CFI execution properties in perms.c (and
rodata.c), we can disable CFI for the involved functions, and remove the
CFI arguments from rodata.c entirely.

Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202308301532.d7acf63e-oliver.sang@intel.com
Fixes: 6342a20efbd8 ("objtool: Add elf_create_section_pair()")
Link: https://lore.kernel.org/r/20240430234953.work.760-kees@kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
drivers/misc/lkdtm/Makefile
drivers/misc/lkdtm/perms.c

index 95ef971b5e1cb4ce836fa0d2286ee2d81e28d8ce..b28701138b4bc2ef56d21011d5de643b641feb40 100644 (file)
@@ -19,7 +19,7 @@ KASAN_SANITIZE_rodata.o                       := n
 KCSAN_SANITIZE_rodata.o                        := n
 KCOV_INSTRUMENT_rodata.o               := n
 OBJECT_FILES_NON_STANDARD_rodata.o     := y
-CFLAGS_REMOVE_rodata.o                 += $(CC_FLAGS_LTO) $(RETHUNK_CFLAGS)
+CFLAGS_REMOVE_rodata.o                 += $(CC_FLAGS_LTO) $(RETHUNK_CFLAGS) $(CC_FLAGS_CFI)
 
 OBJCOPYFLAGS :=
 OBJCOPYFLAGS_rodata_objcopy.o  := \
index b93404d656509283e64bc01d8c62c9e11a0a39ec..5b861dbff27e9a6f945fc9d605d3ec86b40ac216 100644 (file)
@@ -61,7 +61,7 @@ static void *setup_function_descriptor(func_desc_t *fdesc, void *dst)
        return fdesc;
 }
 
-static noinline void execute_location(void *dst, bool write)
+static noinline __nocfi void execute_location(void *dst, bool write)
 {
        void (*func)(void);
        func_desc_t fdesc;