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

objtool: Mark non-standard object files and directories

Code which runs outside the kernel's normal mode of operation often does
unusual things which can cause a static analysis tool like objtool to
emit false positive warnings:

- boot image
- vdso image
- relocation
- realmode
- efi
- head
- purgatory
- modpost

Set OBJECT_FILES_NON_STANDARD for their related files and directories,
which will tell objtool to skip checking them. It's ok to skip them
because they don't affect runtime stack traces.

Also skip the following code which does the right thing with respect to
frame pointers, but is too "special" to be validated by a tool:

- entry
- mcount

Also skip the test_nx module because it modifies its exception handling
table at runtime, which objtool can't understand. Fortunately it's
just a test module so it doesn't matter much.

Currently objtool is the only user of OBJECT_FILES_NON_STANDARD, but it
might eventually be useful for other tools.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Chris J Arges <chris.j.arges@canonical.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Pedro Alves <palves@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: live-patching@vger.kernel.org
Link: http://lkml.kernel.org/r/366c080e3844e8a5b6a0327dc7e8c2b90ca3baeb.1456719558.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Josh Poimboeuf and committed by
Ingo Molnar
c0dd6716 319e305c

+32 -9
+2 -1
arch/x86/boot/Makefile
··· 9 9 # Changed by many, many contributors over the years. 10 10 # 11 11 12 - KASAN_SANITIZE := n 12 + KASAN_SANITIZE := n 13 + OBJECT_FILES_NON_STANDARD := y 13 14 14 15 # If you want to preset the SVGA mode, uncomment the next line and 15 16 # set SVGA_MODE to whatever number you want.
+2 -1
arch/x86/boot/compressed/Makefile
··· 16 16 # (see scripts/Makefile.lib size_append) 17 17 # compressed vmlinux.bin.all + u32 size of vmlinux.bin.all 18 18 19 - KASAN_SANITIZE := n 19 + KASAN_SANITIZE := n 20 + OBJECT_FILES_NON_STANDARD := y 20 21 21 22 targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ 22 23 vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
+4
arch/x86/entry/Makefile
··· 1 1 # 2 2 # Makefile for the x86 low level entry code 3 3 # 4 + 5 + OBJECT_FILES_NON_STANDARD_entry_$(BITS).o := y 6 + OBJECT_FILES_NON_STANDARD_entry_64_compat.o := y 7 + 4 8 obj-y := entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o 5 9 obj-y += common.o 6 10
+4 -2
arch/x86/entry/vdso/Makefile
··· 3 3 # 4 4 5 5 KBUILD_CFLAGS += $(DISABLE_LTO) 6 - KASAN_SANITIZE := n 7 - UBSAN_SANITIZE := n 6 + KASAN_SANITIZE := n 7 + UBSAN_SANITIZE := n 8 + OBJECT_FILES_NON_STANDARD := y 8 9 9 10 VDSO64-$(CONFIG_X86_64) := y 10 11 VDSOX32-$(CONFIG_X86_X32_ABI) := y ··· 17 16 18 17 # files to link into kernel 19 18 obj-y += vma.o 19 + OBJECT_FILES_NON_STANDARD_vma.o := n 20 20 21 21 # vDSO images to build 22 22 vdso_img-$(VDSO64-y) += 64
+8 -3
arch/x86/kernel/Makefile
··· 16 16 CFLAGS_REMOVE_early_printk.o = -pg 17 17 endif 18 18 19 - KASAN_SANITIZE_head$(BITS).o := n 20 - KASAN_SANITIZE_dumpstack.o := n 21 - KASAN_SANITIZE_dumpstack_$(BITS).o := n 19 + KASAN_SANITIZE_head$(BITS).o := n 20 + KASAN_SANITIZE_dumpstack.o := n 21 + KASAN_SANITIZE_dumpstack_$(BITS).o := n 22 + 23 + OBJECT_FILES_NON_STANDARD_head_$(BITS).o := y 24 + OBJECT_FILES_NON_STANDARD_relocate_kernel_$(BITS).o := y 25 + OBJECT_FILES_NON_STANDARD_mcount_$(BITS).o := y 26 + OBJECT_FILES_NON_STANDARD_test_nx.o := y 22 27 23 28 CFLAGS_irq.o := -I$(src)/../include/asm/trace 24 29
+2
arch/x86/platform/efi/Makefile
··· 1 + OBJECT_FILES_NON_STANDARD_efi_thunk_$(BITS).o := y 2 + 1 3 obj-$(CONFIG_EFI) += quirks.o efi.o efi_$(BITS).o efi_stub_$(BITS).o 2 4 obj-$(CONFIG_ACPI_BGRT) += efi-bgrt.o 3 5 obj-$(CONFIG_EARLY_PRINTK_EFI) += early_printk.o
+2
arch/x86/purgatory/Makefile
··· 1 + OBJECT_FILES_NON_STANDARD := y 2 + 1 3 purgatory-y := purgatory.o stack.o setup-x86_$(BITS).o sha256.o entry64.o string.o 2 4 3 5 targets += $(purgatory-y)
+3 -1
arch/x86/realmode/Makefile
··· 6 6 # for more details. 7 7 # 8 8 # 9 - KASAN_SANITIZE := n 9 + KASAN_SANITIZE := n 10 + OBJECT_FILES_NON_STANDARD := y 11 + 10 12 subdir- := rm 11 13 12 14 obj-y += init.o
+2 -1
arch/x86/realmode/rm/Makefile
··· 6 6 # for more details. 7 7 # 8 8 # 9 - KASAN_SANITIZE := n 9 + KASAN_SANITIZE := n 10 + OBJECT_FILES_NON_STANDARD := y 10 11 11 12 always := realmode.bin realmode.relocs 12 13
+1
drivers/firmware/efi/libstub/Makefile
··· 23 23 GCOV_PROFILE := n 24 24 KASAN_SANITIZE := n 25 25 UBSAN_SANITIZE := n 26 + OBJECT_FILES_NON_STANDARD := y 26 27 27 28 lib-y := efi-stub-helper.o 28 29
+2
scripts/mod/Makefile
··· 1 + OBJECT_FILES_NON_STANDARD := y 2 + 1 3 hostprogs-y := modpost mk_elfconfig 2 4 always := $(hostprogs-y) empty.o 3 5