Skip to content

Commit 22922de

Browse files
committed
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 ...
2 parents 2319be1 + 22682a0 commit 22922de

File tree

34 files changed

+955
-683
lines changed

34 files changed

+955
-683
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ install: sub_make_done :=
13021302
# ---------------------------------------------------------------------------
13031303
# Tools
13041304

1305-
ifdef CONFIG_STACK_VALIDATION
1305+
ifdef CONFIG_OBJTOOL
13061306
prepare: tools/objtool
13071307
endif
13081308

arch/Kconfig

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ config JUMP_LABEL
5454
bool "Optimize very unlikely/likely branches"
5555
depends on HAVE_ARCH_JUMP_LABEL
5656
depends on CC_HAS_ASM_GOTO
57+
select OBJTOOL if HAVE_JUMP_LABEL_HACK
5758
help
5859
This option enables a transparent branch optimization that
5960
makes certain almost-always-true or almost-always-false branch
@@ -1034,11 +1035,23 @@ config ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
10341035
depends on MMU
10351036
select ARCH_HAS_ELF_RANDOMIZE
10361037

1038+
config HAVE_OBJTOOL
1039+
bool
1040+
1041+
config HAVE_JUMP_LABEL_HACK
1042+
bool
1043+
1044+
config HAVE_NOINSTR_HACK
1045+
bool
1046+
1047+
config HAVE_NOINSTR_VALIDATION
1048+
bool
1049+
10371050
config HAVE_STACK_VALIDATION
10381051
bool
10391052
help
1040-
Architecture supports the 'objtool check' host tool command, which
1041-
performs compile-time stack metadata validation.
1053+
Architecture supports objtool compile-time frame pointer rule
1054+
validation.
10421055

10431056
config HAVE_RELIABLE_STACKTRACE
10441057
bool
@@ -1308,6 +1321,7 @@ config HAVE_STATIC_CALL
13081321
config HAVE_STATIC_CALL_INLINE
13091322
bool
13101323
depends on HAVE_STATIC_CALL
1324+
select OBJTOOL
13111325

13121326
config HAVE_PREEMPT_DYNAMIC
13131327
bool

arch/x86/Kconfig

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ config X86
188188
select HAVE_CONTEXT_TRACKING if X86_64
189189
select HAVE_CONTEXT_TRACKING_OFFSTACK if HAVE_CONTEXT_TRACKING
190190
select HAVE_C_RECORDMCOUNT
191-
select HAVE_OBJTOOL_MCOUNT if STACK_VALIDATION
191+
select HAVE_OBJTOOL_MCOUNT if HAVE_OBJTOOL
192192
select HAVE_BUILDTIME_MCOUNT_SORT
193193
select HAVE_DEBUG_KMEMLEAK
194194
select HAVE_DMA_CONTIGUOUS
@@ -212,6 +212,7 @@ config X86
212212
select HAVE_IOREMAP_PROT
213213
select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64
214214
select HAVE_IRQ_TIME_ACCOUNTING
215+
select HAVE_JUMP_LABEL_HACK if HAVE_OBJTOOL
215216
select HAVE_KERNEL_BZIP2
216217
select HAVE_KERNEL_GZIP
217218
select HAVE_KERNEL_LZ4
@@ -230,7 +231,10 @@ config X86
230231
select HAVE_MOD_ARCH_SPECIFIC
231232
select HAVE_MOVE_PMD
232233
select HAVE_MOVE_PUD
234+
select HAVE_NOINSTR_HACK if HAVE_OBJTOOL
233235
select HAVE_NMI
236+
select HAVE_NOINSTR_VALIDATION if HAVE_OBJTOOL
237+
select HAVE_OBJTOOL if X86_64
234238
select HAVE_OPTPROBES
235239
select HAVE_PCSPKR_PLATFORM
236240
select HAVE_PERF_EVENTS
@@ -239,17 +243,17 @@ config X86
239243
select HAVE_PCI
240244
select HAVE_PERF_REGS
241245
select HAVE_PERF_USER_STACK_DUMP
242-
select MMU_GATHER_RCU_TABLE_FREE if PARAVIRT
246+
select MMU_GATHER_RCU_TABLE_FREE if PARAVIRT
243247
select HAVE_POSIX_CPU_TIMERS_TASK_WORK
244248
select HAVE_REGS_AND_STACK_ACCESS_API
245-
select HAVE_RELIABLE_STACKTRACE if X86_64 && (UNWINDER_FRAME_POINTER || UNWINDER_ORC) && STACK_VALIDATION
249+
select HAVE_RELIABLE_STACKTRACE if UNWINDER_ORC || STACK_VALIDATION
246250
select HAVE_FUNCTION_ARG_ACCESS_API
247251
select HAVE_SETUP_PER_CPU_AREA
248252
select HAVE_SOFTIRQ_ON_OWN_STACK
249253
select HAVE_STACKPROTECTOR if CC_HAS_SANE_STACKPROTECTOR
250-
select HAVE_STACK_VALIDATION if X86_64
254+
select HAVE_STACK_VALIDATION if HAVE_OBJTOOL
251255
select HAVE_STATIC_CALL
252-
select HAVE_STATIC_CALL_INLINE if HAVE_STACK_VALIDATION
256+
select HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL
253257
select HAVE_PREEMPT_DYNAMIC_CALL
254258
select HAVE_RSEQ
255259
select HAVE_SYSCALL_TRACEPOINTS
@@ -268,7 +272,6 @@ config X86
268272
select RTC_MC146818_LIB
269273
select SPARSE_IRQ
270274
select SRCU
271-
select STACK_VALIDATION if HAVE_STACK_VALIDATION && (HAVE_STATIC_CALL_INLINE || RETPOLINE)
272275
select SYSCTL_EXCEPTION_TRACE
273276
select THREAD_INFO_IN_TASK
274277
select TRACE_IRQFLAGS_SUPPORT
@@ -459,6 +462,7 @@ config GOLDFISH
459462

460463
config RETPOLINE
461464
bool "Avoid speculative indirect branches in kernel"
465+
select OBJTOOL if HAVE_OBJTOOL
462466
default y
463467
help
464468
Compile kernel with the retpoline compiler options to guard against
@@ -472,6 +476,7 @@ config CC_HAS_SLS
472476
config SLS
473477
bool "Mitigate Straight-Line-Speculation"
474478
depends on CC_HAS_SLS && X86_64
479+
select OBJTOOL if HAVE_OBJTOOL
475480
default n
476481
help
477482
Compile the kernel with straight-line-speculation options to guard
@@ -1859,9 +1864,10 @@ config CC_HAS_IBT
18591864
config X86_KERNEL_IBT
18601865
prompt "Indirect Branch Tracking"
18611866
bool
1862-
depends on X86_64 && CC_HAS_IBT && STACK_VALIDATION
1867+
depends on X86_64 && CC_HAS_IBT && HAVE_OBJTOOL
18631868
# https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cdc231f9e579f2d0f
18641869
depends on !LD_IS_LLD || LLD_VERSION >= 140000
1870+
select OBJTOOL
18651871
help
18661872
Build the kernel with support for Indirect Branch Tracking, a
18671873
hardware support course-grain forward-edge Control Flow Integrity

arch/x86/Kconfig.debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ choice
237237
config UNWINDER_ORC
238238
bool "ORC unwinder"
239239
depends on X86_64
240-
select STACK_VALIDATION
240+
select OBJTOOL
241241
help
242242
This option enables the ORC (Oops Rewind Capability) unwinder for
243243
unwinding kernel stack traces. It uses a custom data format which is

arch/x86/include/asm/jump_label.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
_ASM_PTR "%c0 + %c1 - .\n\t" \
2121
".popsection \n\t"
2222

23-
#ifdef CONFIG_STACK_VALIDATION
23+
#ifdef CONFIG_HAVE_JUMP_LABEL_HACK
2424

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

37-
#else
37+
#else /* !CONFIG_HAVE_JUMP_LABEL_HACK */
3838

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

51-
#endif /* STACK_VALIDATION */
51+
#endif /* CONFIG_HAVE_JUMP_LABEL_HACK */
5252

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

arch/x86/kernel/alternative.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
338338
}
339339
}
340340

341-
#if defined(CONFIG_RETPOLINE) && defined(CONFIG_STACK_VALIDATION)
341+
#if defined(CONFIG_RETPOLINE) && defined(CONFIG_OBJTOOL)
342342

343343
/*
344344
* CALL/JMP *%\reg
@@ -507,11 +507,11 @@ void __init_or_module noinline apply_retpolines(s32 *start, s32 *end)
507507
}
508508
}
509509

510-
#else /* !RETPOLINES || !CONFIG_STACK_VALIDATION */
510+
#else /* !CONFIG_RETPOLINE || !CONFIG_OBJTOOL */
511511

512512
void __init_or_module noinline apply_retpolines(s32 *start, s32 *end) { }
513513

514-
#endif /* CONFIG_RETPOLINE && CONFIG_STACK_VALIDATION */
514+
#endif /* CONFIG_RETPOLINE && CONFIG_OBJTOOL */
515515

516516
#ifdef CONFIG_X86_KERNEL_IBT
517517

include/linux/compiler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
109109
#endif
110110

111111
/* Unreachable code */
112-
#ifdef CONFIG_STACK_VALIDATION
112+
#ifdef CONFIG_OBJTOOL
113113
/*
114114
* These macros help objtool understand GCC code flow for unreachable code.
115115
* The __COUNTER__ based labels are a hack to make each instance of the macros
@@ -128,10 +128,10 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
128128
/* Annotate a C jump table to allow objtool to follow the code flow */
129129
#define __annotate_jump_table __section(".rodata..c_jump_table")
130130

131-
#else
131+
#else /* !CONFIG_OBJTOOL */
132132
#define annotate_unreachable()
133133
#define __annotate_jump_table
134-
#endif
134+
#endif /* CONFIG_OBJTOOL */
135135

136136
#ifndef unreachable
137137
# define unreachable() do { \

include/linux/instrumentation.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifndef __LINUX_INSTRUMENTATION_H
33
#define __LINUX_INSTRUMENTATION_H
44

5-
#if defined(CONFIG_DEBUG_ENTRY) && defined(CONFIG_STACK_VALIDATION)
5+
#ifdef CONFIG_NOINSTR_VALIDATION
66

77
#include <linux/stringify.h>
88

@@ -53,9 +53,9 @@
5353
".popsection\n\t" : : "i" (c)); \
5454
})
5555
#define instrumentation_end() __instrumentation_end(__COUNTER__)
56-
#else
56+
#else /* !CONFIG_NOINSTR_VALIDATION */
5757
# define instrumentation_begin() do { } while(0)
5858
# define instrumentation_end() do { } while(0)
59-
#endif
59+
#endif /* CONFIG_NOINSTR_VALIDATION */
6060

6161
#endif /* __LINUX_INSTRUMENTATION_H */

include/linux/objtool.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct unwind_hint {
3838
#define UNWIND_HINT_TYPE_REGS_PARTIAL 2
3939
#define UNWIND_HINT_TYPE_FUNC 3
4040

41-
#ifdef CONFIG_STACK_VALIDATION
41+
#ifdef CONFIG_OBJTOOL
4242

4343
#include <asm/asm.h>
4444

@@ -159,7 +159,7 @@ struct unwind_hint {
159159

160160
#endif /* __ASSEMBLY__ */
161161

162-
#else /* !CONFIG_STACK_VALIDATION */
162+
#else /* !CONFIG_OBJTOOL */
163163

164164
#ifndef __ASSEMBLY__
165165

@@ -181,6 +181,6 @@ struct unwind_hint {
181181
.endm
182182
#endif
183183

184-
#endif /* CONFIG_STACK_VALIDATION */
184+
#endif /* CONFIG_OBJTOOL */
185185

186186
#endif /* _LINUX_OBJTOOL_H */

kernel/trace/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ config FTRACE_MCOUNT_USE_OBJTOOL
729729
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
730730
depends on !FTRACE_MCOUNT_USE_CC
731731
depends on FTRACE_MCOUNT_RECORD
732+
select OBJTOOL
732733

733734
config FTRACE_MCOUNT_USE_RECORDMCOUNT
734735
def_bool y

0 commit comments

Comments
 (0)