]> www.infradead.org Git - users/jedix/linux-maple.git/commit
objtool, lkdtm: Obfuscate the do_nothing() pointer
authorJosh Poimboeuf <jpoimboe@kernel.org>
Mon, 24 Mar 2025 21:56:12 +0000 (14:56 -0700)
committerIngo Molnar <mingo@kernel.org>
Fri, 28 Mar 2025 13:38:09 +0000 (14:38 +0100)
commit05026ea01e95ffdeb0e5ac8fb7fb1b551e3a8726
tree4413c9117e14eddf8a39823d319652115ededd86
parent29c578c848402a34e8c8e115bf66cb6008b77062
objtool, lkdtm: Obfuscate the do_nothing() pointer

If execute_location()'s memcpy of do_nothing() gets inlined and unrolled
by the compiler, it copies one word at a time:

    mov    0x0(%rip),%rax    R_X86_64_PC32    .text+0x1374
    mov    %rax,0x38(%rbx)
    mov    0x0(%rip),%rax    R_X86_64_PC32    .text+0x136c
    mov    %rax,0x30(%rbx)
    ...

Those .text references point to the middle of the function, causing
objtool to complain about their lack of ENDBR.

Prevent that by resolving the function pointer at runtime rather than
build time.  This fixes the following warning:

  drivers/misc/lkdtm/lkdtm.o: warning: objtool: execute_location+0x23: relocation to !ENDBR: .text+0x1378

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/30b9abffbddeb43c4f6320b1270fa9b4d74c54ed.1742852847.git.jpoimboe@kernel.org
Closes: https://lore.kernel.org/oe-kbuild-all/202503191453.uFfxQy5R-lkp@intel.com/
drivers/misc/lkdtm/perms.c