Skip to content

Commit

Permalink
objtool: Mark non-standard object files and directories
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Bernd Petrovitsch <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Chris J Arges <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Michal Marek <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Pedro Alves <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/366c080e3844e8a5b6a0327dc7e8c2b90ca3baeb.1456719558.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
jpoimboe authored and Ingo Molnar committed Feb 29, 2016
1 parent 319e305 commit c0dd671
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 9 deletions.
3 changes: 2 additions & 1 deletion arch/x86/boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# Changed by many, many contributors over the years.
#

KASAN_SANITIZE := n
KASAN_SANITIZE := n
OBJECT_FILES_NON_STANDARD := y

# If you want to preset the SVGA mode, uncomment the next line and
# set SVGA_MODE to whatever number you want.
Expand Down
3 changes: 2 additions & 1 deletion arch/x86/boot/compressed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# (see scripts/Makefile.lib size_append)
# compressed vmlinux.bin.all + u32 size of vmlinux.bin.all

KASAN_SANITIZE := n
KASAN_SANITIZE := n
OBJECT_FILES_NON_STANDARD := y

targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/entry/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#
# Makefile for the x86 low level entry code
#

OBJECT_FILES_NON_STANDARD_entry_$(BITS).o := y
OBJECT_FILES_NON_STANDARD_entry_64_compat.o := y

obj-y := entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o
obj-y += common.o

Expand Down
6 changes: 4 additions & 2 deletions arch/x86/entry/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#

KBUILD_CFLAGS += $(DISABLE_LTO)
KASAN_SANITIZE := n
UBSAN_SANITIZE := n
KASAN_SANITIZE := n
UBSAN_SANITIZE := n
OBJECT_FILES_NON_STANDARD := y

VDSO64-$(CONFIG_X86_64) := y
VDSOX32-$(CONFIG_X86_X32_ABI) := y
Expand All @@ -16,6 +17,7 @@ vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o

# files to link into kernel
obj-y += vma.o
OBJECT_FILES_NON_STANDARD_vma.o := n

# vDSO images to build
vdso_img-$(VDSO64-y) += 64
Expand Down
11 changes: 8 additions & 3 deletions arch/x86/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ CFLAGS_REMOVE_ftrace.o = -pg
CFLAGS_REMOVE_early_printk.o = -pg
endif

KASAN_SANITIZE_head$(BITS).o := n
KASAN_SANITIZE_dumpstack.o := n
KASAN_SANITIZE_dumpstack_$(BITS).o := n
KASAN_SANITIZE_head$(BITS).o := n
KASAN_SANITIZE_dumpstack.o := n
KASAN_SANITIZE_dumpstack_$(BITS).o := n

OBJECT_FILES_NON_STANDARD_head_$(BITS).o := y
OBJECT_FILES_NON_STANDARD_relocate_kernel_$(BITS).o := y
OBJECT_FILES_NON_STANDARD_mcount_$(BITS).o := y
OBJECT_FILES_NON_STANDARD_test_nx.o := y

CFLAGS_irq.o := -I$(src)/../include/asm/trace

Expand Down
2 changes: 2 additions & 0 deletions arch/x86/platform/efi/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
OBJECT_FILES_NON_STANDARD_efi_thunk_$(BITS).o := y

obj-$(CONFIG_EFI) += quirks.o efi.o efi_$(BITS).o efi_stub_$(BITS).o
obj-$(CONFIG_ACPI_BGRT) += efi-bgrt.o
obj-$(CONFIG_EARLY_PRINTK_EFI) += early_printk.o
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/purgatory/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
OBJECT_FILES_NON_STANDARD := y

purgatory-y := purgatory.o stack.o setup-x86_$(BITS).o sha256.o entry64.o string.o

targets += $(purgatory-y)
Expand Down
4 changes: 3 additions & 1 deletion arch/x86/realmode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
# for more details.
#
#
KASAN_SANITIZE := n
KASAN_SANITIZE := n
OBJECT_FILES_NON_STANDARD := y

subdir- := rm

obj-y += init.o
Expand Down
3 changes: 2 additions & 1 deletion arch/x86/realmode/rm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# for more details.
#
#
KASAN_SANITIZE := n
KASAN_SANITIZE := n
OBJECT_FILES_NON_STANDARD := y

always := realmode.bin realmode.relocs

Expand Down
1 change: 1 addition & 0 deletions drivers/firmware/efi/libstub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \
GCOV_PROFILE := n
KASAN_SANITIZE := n
UBSAN_SANITIZE := n
OBJECT_FILES_NON_STANDARD := y

lib-y := efi-stub-helper.o

Expand Down
2 changes: 2 additions & 0 deletions scripts/mod/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
OBJECT_FILES_NON_STANDARD := y

hostprogs-y := modpost mk_elfconfig
always := $(hostprogs-y) empty.o

Expand Down

0 comments on commit c0dd671

Please sign in to comment.