Commit 22922dea authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'objtool-core-2022-05-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull objtool updates from Ingo Molnar:

 - Comprehensive interface overhaul:
   =================================

   Objtool's interface has some issues:

     - Several features are done unconditionally, without any way to
       turn them off. Some of them might be surprising. This makes
       objtool tricky to use, and prevents porting individual features
       to other arches.

     - The config dependencies are too coarse-grained. Objtool
       enablement is tied to CONFIG_STACK_VALIDATION, but it has several
       other features independent of that.

     - The objtool subcmds ("check" and "orc") are clumsy: "check" is
       really a subset of "orc", so it has all the same options.

       The subcmd model has never really worked for objtool, as it only
       has a single purpose: "do some combination of things on an object
       file".

     - The '--lto' and '--vmlinux' options are nonsensical and have
       surprising behavior.

   Overhaul the interface:

      - get rid of subcmds

      - make all features individually selectable

      - remove and/or clarify confusing/obsolete options

      - update the documentation

      - fix some bugs found along the way

 - Fix x32 regression

 - Fix Kbuild cleanup bugs

 - Add scripts/objdump-func helper script to disassemble a single
   function from an object file.

 - Rewrite scripts/faddr2line to be section-aware, by basing it on
   'readelf', moving it away from 'nm', which doesn't handle multiple
   sections well, which can result in decoding failure.

 - Rewrite & fix symbol handling - which had a number of bugs wrt.
   object files that don't have global symbols - which is rare but
   possible. Also fix a bunch of symbol handling bugs found along the
   way.

* tag 'objtool-core-2022-05-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (23 commits)
  objtool: Fix objtool regression on x32 systems
  objtool: Fix symbol creation
  scripts/faddr2line: Fix overlapping text section failures
  scripts: Create objdump-func helper script
  objtool: Remove libsubcmd.a when make clean
  objtool: Remove inat-tables.c when make clean
  objtool: Update documentation
  objtool: Remove --lto and --vmlinux in favor of --link
  objtool: Add HAVE_NOINSTR_VALIDATION
  objtool: Rename "VMLINUX_VALIDATION" -> "NOINSTR_VALIDATION"
  objtool: Make noinstr hacks optional
  objtool: Make jump label hack optional
  objtool: Make static call annotation optional
  objtool: Make stack validation frame-pointer-specific
  objtool: Add CONFIG_OBJTOOL
  objtool: Extricate sls from stack validation
  objtool: Rework ibt and extricate from stack validation
  objtool: Make stack validation optional
  objtool: Add option to print section addresses
  objtool: Don't print parentheses in function addresses
  ...
parents 2319be13 22682a07
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1302,7 +1302,7 @@ install: sub_make_done :=
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# Tools
# Tools


ifdef CONFIG_STACK_VALIDATION
ifdef CONFIG_OBJTOOL
prepare: tools/objtool
prepare: tools/objtool
endif
endif


+16 −2
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ config JUMP_LABEL
	bool "Optimize very unlikely/likely branches"
	bool "Optimize very unlikely/likely branches"
	depends on HAVE_ARCH_JUMP_LABEL
	depends on HAVE_ARCH_JUMP_LABEL
	depends on CC_HAS_ASM_GOTO
	depends on CC_HAS_ASM_GOTO
	select OBJTOOL if HAVE_JUMP_LABEL_HACK
	help
	help
	 This option enables a transparent branch optimization that
	 This option enables a transparent branch optimization that
	 makes certain almost-always-true or almost-always-false branch
	 makes certain almost-always-true or almost-always-false branch
@@ -1034,11 +1035,23 @@ config ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
	depends on MMU
	depends on MMU
	select ARCH_HAS_ELF_RANDOMIZE
	select ARCH_HAS_ELF_RANDOMIZE


config HAVE_OBJTOOL
	bool

config HAVE_JUMP_LABEL_HACK
	bool

config HAVE_NOINSTR_HACK
	bool

config HAVE_NOINSTR_VALIDATION
	bool

config HAVE_STACK_VALIDATION
config HAVE_STACK_VALIDATION
	bool
	bool
	help
	help
	  Architecture supports the 'objtool check' host tool command, which
	  Architecture supports objtool compile-time frame pointer rule
	  performs compile-time stack metadata validation.
	  validation.


config HAVE_RELIABLE_STACKTRACE
config HAVE_RELIABLE_STACKTRACE
	bool
	bool
@@ -1308,6 +1321,7 @@ config HAVE_STATIC_CALL
config HAVE_STATIC_CALL_INLINE
config HAVE_STATIC_CALL_INLINE
	bool
	bool
	depends on HAVE_STATIC_CALL
	depends on HAVE_STATIC_CALL
	select OBJTOOL


config HAVE_PREEMPT_DYNAMIC
config HAVE_PREEMPT_DYNAMIC
	bool
	bool
+13 −7
Original line number Original line Diff line number Diff line
@@ -188,7 +188,7 @@ config X86
	select HAVE_CONTEXT_TRACKING		if X86_64
	select HAVE_CONTEXT_TRACKING		if X86_64
	select HAVE_CONTEXT_TRACKING_OFFSTACK	if HAVE_CONTEXT_TRACKING
	select HAVE_CONTEXT_TRACKING_OFFSTACK	if HAVE_CONTEXT_TRACKING
	select HAVE_C_RECORDMCOUNT
	select HAVE_C_RECORDMCOUNT
	select HAVE_OBJTOOL_MCOUNT		if STACK_VALIDATION
	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
	select HAVE_BUILDTIME_MCOUNT_SORT
	select HAVE_BUILDTIME_MCOUNT_SORT
	select HAVE_DEBUG_KMEMLEAK
	select HAVE_DEBUG_KMEMLEAK
	select HAVE_DMA_CONTIGUOUS
	select HAVE_DMA_CONTIGUOUS
@@ -212,6 +212,7 @@ config X86
	select HAVE_IOREMAP_PROT
	select HAVE_IOREMAP_PROT
	select HAVE_IRQ_EXIT_ON_IRQ_STACK	if X86_64
	select HAVE_IRQ_EXIT_ON_IRQ_STACK	if X86_64
	select HAVE_IRQ_TIME_ACCOUNTING
	select HAVE_IRQ_TIME_ACCOUNTING
	select HAVE_JUMP_LABEL_HACK		if HAVE_OBJTOOL
	select HAVE_KERNEL_BZIP2
	select HAVE_KERNEL_BZIP2
	select HAVE_KERNEL_GZIP
	select HAVE_KERNEL_GZIP
	select HAVE_KERNEL_LZ4
	select HAVE_KERNEL_LZ4
@@ -230,7 +231,10 @@ config X86
	select HAVE_MOD_ARCH_SPECIFIC
	select HAVE_MOD_ARCH_SPECIFIC
	select HAVE_MOVE_PMD
	select HAVE_MOVE_PMD
	select HAVE_MOVE_PUD
	select HAVE_MOVE_PUD
	select HAVE_NOINSTR_HACK		if HAVE_OBJTOOL
	select HAVE_NMI
	select HAVE_NMI
	select HAVE_NOINSTR_VALIDATION		if HAVE_OBJTOOL
	select HAVE_OBJTOOL			if X86_64
	select HAVE_OPTPROBES
	select HAVE_OPTPROBES
	select HAVE_PCSPKR_PLATFORM
	select HAVE_PCSPKR_PLATFORM
	select HAVE_PERF_EVENTS
	select HAVE_PERF_EVENTS
@@ -242,14 +246,14 @@ config X86
	select MMU_GATHER_RCU_TABLE_FREE	if PARAVIRT
	select MMU_GATHER_RCU_TABLE_FREE	if PARAVIRT
	select HAVE_POSIX_CPU_TIMERS_TASK_WORK
	select HAVE_POSIX_CPU_TIMERS_TASK_WORK
	select HAVE_REGS_AND_STACK_ACCESS_API
	select HAVE_REGS_AND_STACK_ACCESS_API
	select HAVE_RELIABLE_STACKTRACE		if X86_64 && (UNWINDER_FRAME_POINTER || UNWINDER_ORC) && STACK_VALIDATION
	select HAVE_RELIABLE_STACKTRACE		if UNWINDER_ORC || STACK_VALIDATION
	select HAVE_FUNCTION_ARG_ACCESS_API
	select HAVE_FUNCTION_ARG_ACCESS_API
	select HAVE_SETUP_PER_CPU_AREA
	select HAVE_SETUP_PER_CPU_AREA
	select HAVE_SOFTIRQ_ON_OWN_STACK
	select HAVE_SOFTIRQ_ON_OWN_STACK
	select HAVE_STACKPROTECTOR		if CC_HAS_SANE_STACKPROTECTOR
	select HAVE_STACKPROTECTOR		if CC_HAS_SANE_STACKPROTECTOR
	select HAVE_STACK_VALIDATION		if X86_64
	select HAVE_STACK_VALIDATION		if HAVE_OBJTOOL
	select HAVE_STATIC_CALL
	select HAVE_STATIC_CALL
	select HAVE_STATIC_CALL_INLINE		if HAVE_STACK_VALIDATION
	select HAVE_STATIC_CALL_INLINE		if HAVE_OBJTOOL
	select HAVE_PREEMPT_DYNAMIC_CALL
	select HAVE_PREEMPT_DYNAMIC_CALL
	select HAVE_RSEQ
	select HAVE_RSEQ
	select HAVE_SYSCALL_TRACEPOINTS
	select HAVE_SYSCALL_TRACEPOINTS
@@ -268,7 +272,6 @@ config X86
	select RTC_MC146818_LIB
	select RTC_MC146818_LIB
	select SPARSE_IRQ
	select SPARSE_IRQ
	select SRCU
	select SRCU
	select STACK_VALIDATION			if HAVE_STACK_VALIDATION && (HAVE_STATIC_CALL_INLINE || RETPOLINE)
	select SYSCTL_EXCEPTION_TRACE
	select SYSCTL_EXCEPTION_TRACE
	select THREAD_INFO_IN_TASK
	select THREAD_INFO_IN_TASK
	select TRACE_IRQFLAGS_SUPPORT
	select TRACE_IRQFLAGS_SUPPORT
@@ -459,6 +462,7 @@ config GOLDFISH


config RETPOLINE
config RETPOLINE
	bool "Avoid speculative indirect branches in kernel"
	bool "Avoid speculative indirect branches in kernel"
	select OBJTOOL if HAVE_OBJTOOL
	default y
	default y
	help
	help
	  Compile kernel with the retpoline compiler options to guard against
	  Compile kernel with the retpoline compiler options to guard against
@@ -472,6 +476,7 @@ config CC_HAS_SLS
config SLS
config SLS
	bool "Mitigate Straight-Line-Speculation"
	bool "Mitigate Straight-Line-Speculation"
	depends on CC_HAS_SLS && X86_64
	depends on CC_HAS_SLS && X86_64
	select OBJTOOL if HAVE_OBJTOOL
	default n
	default n
	help
	help
	  Compile the kernel with straight-line-speculation options to guard
	  Compile the kernel with straight-line-speculation options to guard
@@ -1859,9 +1864,10 @@ config CC_HAS_IBT
config X86_KERNEL_IBT
config X86_KERNEL_IBT
	prompt "Indirect Branch Tracking"
	prompt "Indirect Branch Tracking"
	bool
	bool
	depends on X86_64 && CC_HAS_IBT && STACK_VALIDATION
	depends on X86_64 && CC_HAS_IBT && HAVE_OBJTOOL
	# https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cdc231f9e579f2d0f
	# https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cdc231f9e579f2d0f
	depends on !LD_IS_LLD || LLD_VERSION >= 140000
	depends on !LD_IS_LLD || LLD_VERSION >= 140000
	select OBJTOOL
	help
	help
	  Build the kernel with support for Indirect Branch Tracking, a
	  Build the kernel with support for Indirect Branch Tracking, a
	  hardware support course-grain forward-edge Control Flow Integrity
	  hardware support course-grain forward-edge Control Flow Integrity
+1 −1
Original line number Original line Diff line number Diff line
@@ -237,7 +237,7 @@ choice
config UNWINDER_ORC
config UNWINDER_ORC
	bool "ORC unwinder"
	bool "ORC unwinder"
	depends on X86_64
	depends on X86_64
	select STACK_VALIDATION
	select OBJTOOL
	help
	help
	  This option enables the ORC (Oops Rewind Capability) unwinder for
	  This option enables the ORC (Oops Rewind Capability) unwinder for
	  unwinding kernel stack traces.  It uses a custom data format which is
	  unwinding kernel stack traces.  It uses a custom data format which is
+3 −3
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@
	_ASM_PTR "%c0 + %c1 - .\n\t"			\
	_ASM_PTR "%c0 + %c1 - .\n\t"			\
	".popsection \n\t"
	".popsection \n\t"


#ifdef CONFIG_STACK_VALIDATION
#ifdef CONFIG_HAVE_JUMP_LABEL_HACK


static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
{
{
@@ -34,7 +34,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran
	return true;
	return true;
}
}


#else
#else /* !CONFIG_HAVE_JUMP_LABEL_HACK */


static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch)
static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch)
{
{
@@ -48,7 +48,7 @@ static __always_inline bool arch_static_branch(struct static_key * const key, co
	return true;
	return true;
}
}


#endif /* STACK_VALIDATION */
#endif /* CONFIG_HAVE_JUMP_LABEL_HACK */


static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch)
static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch)
{
{
Loading