objtool changes for v4.13
Subsystems (11)
Linus,
Please pull the latest core-objtool-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-objtool-for-linus
# HEAD: 2513cbf9d622d85268655bfd787d4f004342cfc9 objtool: Silence warnings for functions which use IRET
This is an extensive rewrite of the objdump tool to track all stack pointer modifications through the machine instructions of disassembled functions found in kernel .o files.
This re-design removes the prior dependency on CONFIG_FRAME_POINTERS=y, with the goal to prepare the tool to generate kernel debuginfo data in the future. There's also an increase in checking/tracking robustness as a side effect as well.
No (intended) changes to existing functionality.
Thanks,
Ingo
------------------>
Josh Poimboeuf (4):
objtool: Move checking code to check.c
objtool, x86: Add several functions and files to the objtool whitelist
objtool: Implement stack validation 2.0
objtool: Silence warnings for functions which use IRET
arch/x86/crypto/Makefile | 2 + arch/x86/crypto/sha1-mb/Makefile | 2 + arch/x86/crypto/sha256-mb/Makefile | 2 + arch/x86/kernel/Makefile | 1 + arch/x86/kernel/acpi/Makefile | 2 + arch/x86/kernel/kprobes/opt.c | 9 +- arch/x86/kernel/reboot.c | 2 + arch/x86/kvm/svm.c | 2 + arch/x86/kvm/vmx.c | 3 + arch/x86/lib/msr-reg.S | 8 +- arch/x86/net/Makefile | 2 + arch/x86/platform/efi/Makefile | 1 + arch/x86/power/Makefile | 2 + arch/x86/xen/Makefile | 3 + kernel/kexec_core.c | 4 +- tools/objtool/Build | 1 + tools/objtool/Documentation/stack-validation.txt | 153 +- tools/objtool/Makefile | 2 +- tools/objtool/arch.h | 64 +- tools/objtool/arch/x86/decode.c | 400 +++++- tools/objtool/builtin-check.c | 1281 +---------------- tools/objtool/cfi.h | 55 + tools/objtool/check.c | 1655 ++++++++++++++++++++++ tools/objtool/check.h | 66 + tools/objtool/elf.c | 59 +- tools/objtool/elf.h | 6 +- tools/objtool/special.c | 6 +- tools/objtool/warn.h | 10 + 28 files changed, 2352 insertions(+), 1451 deletions(-) create mode 100644 tools/objtool/cfi.h create mode 100644 tools/objtool/check.c create mode 100644 tools/objtool/check.h
arch/x86/crypto/Makefile +2 -0
@@ -2,6 +2,8 @@ # Arch-specific CryptoAPI modules. # +OBJECT_FILES_NON_STANDARD := y + avx_supported := $(call as-instr,vpxor %xmm0$(comma)%xmm0$(comma)%xmm0,yes,no) avx2_supported := $(call as-instr,vpgatherdd %ymm0$(comma)(%eax$(comma)%ymm1\ $(comma)4)$(comma)%ymm2,yes,no)
arch/x86/crypto/sha1-mb/Makefile +2 -0
@@ -2,6 +2,8 @@ # Arch-specific CryptoAPI modules. # +OBJECT_FILES_NON_STANDARD := y + avx2_supported := $(call as-instr,vpgatherdd %ymm0$(comma)(%eax$(comma)%ymm1\ $(comma)4)$(comma)%ymm2,yes,no) ifeq ($(avx2_supported),yes)
arch/x86/crypto/sha256-mb/Makefile +2 -0
@@ -2,6 +2,8 @@ # Arch-specific CryptoAPI modules. # +OBJECT_FILES_NON_STANDARD := y + avx2_supported := $(call as-instr,vpgatherdd %ymm0$(comma)(%eax$(comma)%ymm1\ $(comma)4)$(comma)%ymm2,yes,no) ifeq ($(avx2_supported),yes)
arch/x86/kernel/Makefile +1 -0
@@ -29,6 +29,7 @@ OBJECT_FILES_NON_STANDARD_head_$(BITS).o := y OBJECT_FILES_NON_STANDARD_relocate_kernel_$(BITS).o := y OBJECT_FILES_NON_STANDARD_ftrace_$(BITS).o := y OBJECT_FILES_NON_STANDARD_test_nx.o := y +OBJECT_FILES_NON_STANDARD_paravirt_patch_$(BITS).o := y # If instrumentation of this dir is enabled, boot hangs during first second. # Probably could be more selective here, but note that files related to irqs,
arch/x86/kernel/acpi/Makefile +2 -0
@@ -1,3 +1,5 @@ +OBJECT_FILES_NON_STANDARD_wakeup_$(BITS).o := y + obj-$(CONFIG_ACPI) += boot.o obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup_$(BITS).o obj-$(CONFIG_ACPI_APEI) += apei.o
arch/x86/kernel/kprobes/opt.c +8 -1
@@ -28,6 +28,7 @@#include <linux/kdebug.h> #include <linux/kallsyms.h> #include <linux/ftrace.h> +#include <linux/frame.h> #include <asm/text-patching.h> #include <asm/cacheflush.h>
@@ -94,6 +95,7 @@ static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val) } asm ( + "optprobe_template_func:\n" ".global optprobe_template_entry\n" "optprobe_template_entry:\n"#ifdef CONFIG_X86_64
@@ -131,7 +133,12 @@ asm (" popf\n" #endif".global optprobe_template_end\n" - "optprobe_template_end:\n"); +"optprobe_template_end:\n" +".type optprobe_template_func, @function\n" + ".size optprobe_template_func, .-optprobe_template_func\n"); + +void optprobe_template_func (void ); +STACK_FRAME_NON_STANDARD (optprobe_template_func);#define TMPL_MOVE_IDX \ ((long)&optprobe_template_val - (long)&optprobe_template_entry)
arch/x86/kernel/reboot.c +2 -0
@@ -9,6 +9,7 @@#include <linux/sched.h> #include <linux/tboot.h> #include <linux/delay.h> +#include <linux/frame.h> #include <acpi/reboot.h> #include <asm/io.h> #include <asm/apic.h>
@@ -123,6 +124,7 @@ void __noreturn machine_real_restart(unsigned int type)#ifdef CONFIG_APM_MODULE EXPORT_SYMBOL (machine_real_restart);#endif +STACK_FRAME_NON_STANDARD (machine_real_restart);/* * Some Apple MacBook and MacBookPro's needs reboot=p to be able to reboot
arch/x86/kvm/svm.c +2 -0
@@ -36,6 +36,7 @@#include <linux/slab.h> #include <linux/amd-iommu.h> #include <linux/hashtable.h> +#include <linux/frame.h> #include <asm/apic.h> #include <asm/perf_event.h>
@@ -4906,6 +4907,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)mark_all_clean (svm->vmcb); } +STACK_FRAME_NON_STANDARD (svm_vcpu_run);static void svm_set_cr3 (struct kvm_vcpu *vcpu,unsigned long root) {
arch/x86/kvm/vmx.c +3 -0
@@ -33,6 +33,7 @@#include <linux/slab.h> #include <linux/tboot.h> #include <linux/hrtimer.h> +#include <linux/frame.h> #include "kvm_cache_regs.h" #include "x86.h"
@@ -8652,6 +8653,7 @@ static void vmx_handle_external_intr(struct kvm_vcpu *vcpu) ); } } +STACK_FRAME_NON_STANDARD (vmx_handle_external_intr);static bool vmx_has_high_real_mode_segbase (void ) {
@@ -9028,6 +9030,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)vmx_recover_nmi_blocking (vmx);vmx_complete_interrupts (vmx); } +STACK_FRAME_NON_STANDARD (vmx_vcpu_run);static void vmx_switch_vmcs (struct kvm_vcpu *vcpu,struct loaded_vmcs *vmcs) {
arch/x86/lib/msr-reg.S +4 -4
@@ -13,14 +13,14 @@ .macro op_safe_regs op ENTRY(\op\()_safe_regs) pushq %rbx - pushq %rbp + pushq %r12 movq %rdi, %r10 /* Save pointer */ xorl %r11d, %r11d /* Return value */ movl (%rdi), %eax movl 4(%rdi), %ecx movl 8(%rdi), %edx movl 12(%rdi), %ebx - movl 20(%rdi), %ebp + movl 20(%rdi), %r12d movl 24(%rdi), %esi movl 28(%rdi), %edi 1: \op
@@ -29,10 +29,10 @@ ENTRY(\op\()_safe_regs) movl %ecx, 4(%r10) movl %edx, 8(%r10) movl %ebx, 12(%r10) - movl %ebp, 20(%r10) + movl %r12d, 20(%r10) movl %esi, 24(%r10) movl %edi, 28(%r10) - popq %rbp + popq %r12 popq %rbx ret 3:
arch/x86/net/Makefile +2 -0
@@ -1,4 +1,6 @@ # # Arch-specific network modules # +OBJECT_FILES_NON_STANDARD_bpf_jit.o += y + obj-$(CONFIG_BPF_JIT) += bpf_jit.o bpf_jit_comp.o
arch/x86/platform/efi/Makefile +1 -0
@@ -1,4 +1,5 @@ OBJECT_FILES_NON_STANDARD_efi_thunk_$(BITS).o := y +OBJECT_FILES_NON_STANDARD_efi_stub_$(BITS).o := y obj-$(CONFIG_EFI) += quirks.o efi.o efi_$(BITS).o efi_stub_$(BITS).o obj-$(CONFIG_EARLY_PRINTK_EFI) += early_printk.o
arch/x86/power/Makefile +2 -0
@@ -1,3 +1,5 @@ +OBJECT_FILES_NON_STANDARD_hibernate_asm_$(BITS).o := y + # __restore_processor_state() restores %gs after S3 resume and so should not # itself be stack-protected nostackp := $(call cc-option, -fno-stack-protector)
arch/x86/xen/Makefile +3 -0
@@ -1,3 +1,6 @@ +OBJECT_FILES_NON_STANDARD_xen-asm_$(BITS).o := y +OBJECT_FILES_NON_STANDARD_xen-pvh.o := y + ifdef CONFIG_FUNCTION_TRACER # Do not profile debug and lowlevel utilities CFLAGS_REMOVE_spinlock.o = -pg
kernel/kexec_core.c +3 -1
@@ -38,6 +38,7 @@#include <linux/syscore_ops.h> #include <linux/compiler.h> #include <linux/hugetlb.h> +#include <linux/frame.h> #include <asm/page.h> #include <asm/sections.h>
@@ -874,7 +875,7 @@ int kexec_load_disabled;* only when panic_cpu holds the current CPU number; this is the only CPU * which processes crash_kexec routines. */ -void __crash_kexec (struct pt_regs *regs) +void __noclone __crash_kexec (struct pt_regs *regs) {/* Take the kexec_mutex here to prevent sys_kexec_load * running on one cpu from replacing the crash kernel
@@ -896,6 +897,7 @@ void __crash_kexec(struct pt_regs *regs)mutex_unlock (&kexec_mutex); } } +STACK_FRAME_NON_STANDARD (__crash_kexec);void crash_kexec (struct pt_regs *regs) {
tools/objtool/Build +1 -0
@@ -1,5 +1,6 @@ objtool-y += arch/$(SRCARCH)/ objtool-y += builtin-check.o +objtool-y += check.o objtool-y += elf.o objtool-y += special.o objtool-y += objtool.o
tools/objtool/Documentation/stack-validation.txt +65 -88
219 lines not on this page · raw message
tools/objtool/Makefile +1 -1
@@ -25,7 +25,7 @@ OBJTOOL_IN := $(OBJTOOL)-in.o all: $(OBJTOOL) INCLUDES := -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi -CFLAGS += -Wall -Werror $(EXTRA_WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES) +CFLAGS += -Wall -Werror $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -fomit-frame-pointer -O2 -g $(INCLUDES) LDFLAGS += -lelf $(LIBSUBCMD) # Allow old libelf to be used:
tools/objtool/arch.h +51 -13
76 lines not on this page · raw message
tools/objtool/arch/x86/decode.c +362 -38
476 lines not on this page · raw message
tools/objtool/builtin-check.c +13 -1268
1,305 lines not on this page · raw message
tools/objtool/cfi.h new file +55 -0
55 lines not on this page · raw message
tools/objtool/check.c new file +1655 -0
671 lines not on this page · raw message
tools/objtool/check.h new file +66 -0
66 lines not on this page · raw message
tools/objtool/elf.c +28 -31
59 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.