Now that stack validation is an optional feature of objtool, add CONFIG_OBJTOOL and replace most usages of CONFIG_STACK_VALIDATION with it. CONFIG_STACK_VALIDATION can now be considered to be frame-pointer specific. CONFIG_UNWINDER_ORC is already inherently valid for live patching, so no need to "validate" it.
Unified · Split
| @@ -1302,7 +1302,7 @@ install: sub_make_done := · 1301 unmodified lines | |||
| 1302 | # --------------------------------------------------------------------------- | 1302 | # --------------------------------------------------------------------------- |
| 1303 | # Tools | 1303 | # Tools |
| 1304 | 1304 | ||
| 1305 | ifdef CONFIG_STACK_VALIDATION | 1305 | ifdef CONFIG_OBJTOOL |
| 1306 | prepare: tools/objtool | 1306 | prepare: tools/objtool |
| 1307 | endif | 1307 | endif |
| 1308 | 1308 | ||
| @@ -1028,11 +1028,14 @@ config ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT · 1027 unmodified lines | |||
| 1028 | depends on MMU | 1028 | depends on MMU |
| 1029 | select ARCH_HAS_ELF_RANDOMIZE | 1029 | select ARCH_HAS_ELF_RANDOMIZE |
| 1030 | 1030 | ||
| 1031 | config HAVE_OBJTOOL | ||
| 1032 | bool | ||
| 1033 | |||
| 1031 | config HAVE_STACK_VALIDATION | 1034 | config HAVE_STACK_VALIDATION |
| 1032 | bool | 1035 | bool |
| 1033 | help | 1036 | help |
| 1034 | Architecture supports the 'objtool check' host tool command, which | 1037 | Architecture supports objtool compile-time frame pointer rule |
| 1035 | performs compile-time stack metadata validation. | 1038 | validation. |
| 1036 | 1039 | ||
| 1037 | config HAVE_RELIABLE_STACKTRACE | 1040 | config HAVE_RELIABLE_STACKTRACE |
| 1038 | bool | 1041 | bool |
| @@ -1302,6 +1305,7 @@ config HAVE_STATIC_CALL · 263 unmodified lines | |||
| 1302 | config HAVE_STATIC_CALL_INLINE | 1305 | config HAVE_STATIC_CALL_INLINE |
| 1303 | bool | 1306 | bool |
| 1304 | depends on HAVE_STATIC_CALL | 1307 | depends on HAVE_STATIC_CALL |
| 1308 | select OBJTOOL | ||
| 1305 | 1309 | ||
| 1306 | config HAVE_PREEMPT_DYNAMIC | 1310 | config HAVE_PREEMPT_DYNAMIC |
| 1307 | bool | 1311 | bool |
| @@ -188,7 +188,7 @@ config X86 · 187 unmodified lines | |||
| 188 | select HAVE_CONTEXT_TRACKING if X86_64 | 188 | select HAVE_CONTEXT_TRACKING if X86_64 |
| 189 | select HAVE_CONTEXT_TRACKING_OFFSTACK if HAVE_CONTEXT_TRACKING | 189 | select HAVE_CONTEXT_TRACKING_OFFSTACK if HAVE_CONTEXT_TRACKING |
| 190 | select HAVE_C_RECORDMCOUNT | 190 | select HAVE_C_RECORDMCOUNT |
| 191 | select HAVE_OBJTOOL_MCOUNT if STACK_VALIDATION | 191 | select HAVE_OBJTOOL_MCOUNT if HAVE_OBJTOOL |
| 192 | select HAVE_BUILDTIME_MCOUNT_SORT | 192 | select HAVE_BUILDTIME_MCOUNT_SORT |
| 193 | select HAVE_DEBUG_KMEMLEAK | 193 | select HAVE_DEBUG_KMEMLEAK |
| 194 | select HAVE_DMA_CONTIGUOUS | 194 | select HAVE_DMA_CONTIGUOUS |
| @@ -231,6 +231,7 @@ config X86 · 36 unmodified lines | |||
| 231 | select HAVE_MOVE_PMD | 231 | select HAVE_MOVE_PMD |
| 232 | select HAVE_MOVE_PUD | 232 | select HAVE_MOVE_PUD |
| 233 | select HAVE_NMI | 233 | select HAVE_NMI |
| 234 | select HAVE_OBJTOOL if X86_64 | ||
| 234 | select HAVE_OPTPROBES | 235 | select HAVE_OPTPROBES |
| 235 | select HAVE_PCSPKR_PLATFORM | 236 | select HAVE_PCSPKR_PLATFORM |
| 236 | select HAVE_PERF_EVENTS | 237 | select HAVE_PERF_EVENTS |
| @@ -239,17 +240,17 @@ config X86 · 2 unmodified lines | |||
| 239 | select HAVE_PCI | 240 | select HAVE_PCI |
| 240 | select HAVE_PERF_REGS | 241 | select HAVE_PERF_REGS |
| 241 | select HAVE_PERF_USER_STACK_DUMP | 242 | select HAVE_PERF_USER_STACK_DUMP |
| 242 | select MMU_GATHER_RCU_TABLE_FREE if PARAVIRT | 243 | select MMU_GATHER_RCU_TABLE_FREE if PARAVIRT |
| 243 | select HAVE_POSIX_CPU_TIMERS_TASK_WORK | 244 | select HAVE_POSIX_CPU_TIMERS_TASK_WORK |
| 244 | select HAVE_REGS_AND_STACK_ACCESS_API | 245 | select HAVE_REGS_AND_STACK_ACCESS_API |
| 245 | select HAVE_RELIABLE_STACKTRACE if X86_64 && (UNWINDER_FRAME_POINTER || UNWINDER_ORC) && STACK_VALIDATION | 246 | select HAVE_RELIABLE_STACKTRACE if UNWINDER_ORC || STACK_VALIDATION |
| 246 | select HAVE_FUNCTION_ARG_ACCESS_API | 247 | select HAVE_FUNCTION_ARG_ACCESS_API |
| 247 | select HAVE_SETUP_PER_CPU_AREA | 248 | select HAVE_SETUP_PER_CPU_AREA |
| 248 | select HAVE_SOFTIRQ_ON_OWN_STACK | 249 | select HAVE_SOFTIRQ_ON_OWN_STACK |
| 249 | select HAVE_STACKPROTECTOR if CC_HAS_SANE_STACKPROTECTOR | 250 | select HAVE_STACKPROTECTOR if CC_HAS_SANE_STACKPROTECTOR |
| 250 | select HAVE_STACK_VALIDATION if X86_64 | 251 | select HAVE_STACK_VALIDATION if HAVE_OBJTOOL |
| 251 | select HAVE_STATIC_CALL | 252 | select HAVE_STATIC_CALL |
| 252 | select HAVE_STATIC_CALL_INLINE if HAVE_STACK_VALIDATION | 253 | select HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL |
| 253 | select HAVE_PREEMPT_DYNAMIC_CALL | 254 | select HAVE_PREEMPT_DYNAMIC_CALL |
| 254 | select HAVE_RSEQ | 255 | select HAVE_RSEQ |
| 255 | select HAVE_SYSCALL_TRACEPOINTS | 256 | select HAVE_SYSCALL_TRACEPOINTS |
| @@ -268,7 +269,6 @@ config X86 · 12 unmodified lines | |||
| 268 | select RTC_MC146818_LIB | 269 | select RTC_MC146818_LIB |
| 269 | select SPARSE_IRQ | 270 | select SPARSE_IRQ |
| 270 | select SRCU | 271 | select SRCU |
| 271 | select STACK_VALIDATION if HAVE_STACK_VALIDATION && (HAVE_STATIC_CALL_INLINE || RETPOLINE) | ||
| 272 | select SYSCTL_EXCEPTION_TRACE | 272 | select SYSCTL_EXCEPTION_TRACE |
| 273 | select THREAD_INFO_IN_TASK | 273 | select THREAD_INFO_IN_TASK |
| 274 | select TRACE_IRQFLAGS_SUPPORT | 274 | select TRACE_IRQFLAGS_SUPPORT |
| @@ -459,6 +459,7 @@ config GOLDFISH · 184 unmodified lines | |||
| 459 | 459 | ||
| 460 | config RETPOLINE | 460 | config RETPOLINE |
| 461 | bool "Avoid speculative indirect branches in kernel" | 461 | bool "Avoid speculative indirect branches in kernel" |
| 462 | select OBJTOOL if HAVE_OBJTOOL | ||
| 462 | default y | 463 | default y |
| 463 | help | 464 | help |
| 464 | Compile kernel with the retpoline compiler options to guard against | 465 | Compile kernel with the retpoline compiler options to guard against |
| @@ -472,6 +473,7 @@ config CC_HAS_SLS · 7 unmodified lines | |||
| 472 | config SLS | 473 | config SLS |
| 473 | bool "Mitigate Straight-Line-Speculation" | 474 | bool "Mitigate Straight-Line-Speculation" |
| 474 | depends on CC_HAS_SLS && X86_64 | 475 | depends on CC_HAS_SLS && X86_64 |
| 476 | select OBJTOOL if HAVE_OBJTOOL | ||
| 475 | default n | 477 | default n |
| 476 | help | 478 | help |
| 477 | Compile the kernel with straight-line-speculation options to guard | 479 | Compile the kernel with straight-line-speculation options to guard |
| @@ -1819,6 +1821,7 @@ config ARCH_RANDOM · 1341 unmodified lines | |||
| 1819 | config X86_SMAP | 1821 | config X86_SMAP |
| 1820 | def_bool y | 1822 | def_bool y |
| 1821 | prompt "Supervisor Mode Access Prevention" if EXPERT | 1823 | prompt "Supervisor Mode Access Prevention" if EXPERT |
| 1824 | select OBJTOOL if HAVE_OBJTOOL | ||
| 1822 | help | 1825 | help |
| 1823 | Supervisor Mode Access Prevention (SMAP) is a security | 1826 | Supervisor Mode Access Prevention (SMAP) is a security |
| 1824 | feature in newer Intel processors. There is a small | 1827 | feature in newer Intel processors. There is a small |
| @@ -1855,9 +1858,10 @@ config CC_HAS_IBT · 30 unmodified lines | |||
| 1855 | config X86_KERNEL_IBT | 1858 | config X86_KERNEL_IBT |
| 1856 | prompt "Indirect Branch Tracking" | 1859 | prompt "Indirect Branch Tracking" |
| 1857 | bool | 1860 | bool |
| 1858 | depends on X86_64 && CC_HAS_IBT && STACK_VALIDATION | 1861 | depends on X86_64 && CC_HAS_IBT && HAVE_OBJTOOL |
| 1859 | # https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cdc231f9e579f2d0f | 1862 | # https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cdc231f9e579f2d0f |
| 1860 | depends on !LD_IS_LLD || LLD_VERSION >= 140000 | 1863 | depends on !LD_IS_LLD || LLD_VERSION >= 140000 |
| 1864 | select OBJTOOL | ||
| 1861 | help | 1865 | help |
| 1862 | Build the kernel with support for Indirect Branch Tracking, a | 1866 | Build the kernel with support for Indirect Branch Tracking, a |
| 1863 | hardware support course-grain forward-edge Control Flow Integrity | 1867 | hardware support course-grain forward-edge Control Flow Integrity |
| @@ -237,7 +237,7 @@ choice · 236 unmodified lines | |||
| 237 | config UNWINDER_ORC | 237 | config UNWINDER_ORC |
| 238 | bool "ORC unwinder" | 238 | bool "ORC unwinder" |
| 239 | depends on X86_64 | 239 | depends on X86_64 |
| 240 | select STACK_VALIDATION | 240 | select OBJTOOL |
| 241 | help | 241 | help |
| 242 | This option enables the ORC (Oops Rewind Capability) unwinder for | 242 | This option enables the ORC (Oops Rewind Capability) unwinder for |
| 243 | unwinding kernel stack traces. It uses a custom data format which is | 243 | unwinding kernel stack traces. It uses a custom data format which is |
| @@ -20,7 +20,7 @@ · 19 unmodified lines | |||
| 20 | _ASM_PTR "%c0 + %c1 - .\n\t" \ | 20 | _ASM_PTR "%c0 + %c1 - .\n\t" \ |
| 21 | ".popsection \n\t" | 21 | ".popsection \n\t" |
| 22 | 22 | ||
| 23 | #ifdef CONFIG_STACK_VALIDATION | 23 | #ifdef CONFIG_OBJTOOL |
| 24 | 24 | ||
| 25 | static __always_inline bool arch_static_branch(struct static_key *key, bool branch) | 25 | static __always_inline bool arch_static_branch(struct static_key *key, bool branch) |
| 26 | { | 26 | { |
| @@ -34,7 +34,7 @@ l_yes: · 7 unmodified lines | |||
| 34 | return true; | 34 | return true; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | #else | 37 | #else /* !CONFIG_OBJTOOL */ |
| 38 | 38 | ||
| 39 | static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch) | 39 | static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch) |
| 40 | { | 40 | { |
| @@ -48,7 +48,7 @@ l_yes: · 7 unmodified lines | |||
| 48 | return true; | 48 | return true; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | #endif /* STACK_VALIDATION */ | 51 | #endif /* CONFIG_OBJTOOL */ |
| 52 | 52 | ||
| 53 | static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch) | 53 | static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch) |
| 54 | { | 54 | { |
| @@ -338,7 +338,7 @@ next: · 337 unmodified lines | |||
| 338 | } | 338 | } |
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | #if defined(CONFIG_RETPOLINE) && defined(CONFIG_STACK_VALIDATION) | 341 | #if defined(CONFIG_RETPOLINE) && defined(CONFIG_OBJTOOL) |
| 342 | 342 | ||
| 343 | /* | 343 | /* |
| 344 | * CALL/JMP *%\reg | 344 | * CALL/JMP *%\reg |
| @@ -507,11 +507,11 @@ void __init_or_module noinline apply_retpolines(s32 *start, s32 *end) · 162 unmodified lines | |||
| 507 | } | 507 | } |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | #else /* !RETPOLINES || !CONFIG_STACK_VALIDATION */ | 510 | #else /* !CONFIG_RETPOLINE || !CONFIG_OBJTOOL */ |
| 511 | 511 | ||
| 512 | void __init_or_module noinline apply_retpolines(s32 *start, s32 *end) { } | 512 | void __init_or_module noinline apply_retpolines(s32 *start, s32 *end) { } |
| 513 | 513 | ||
| 514 | #endif /* CONFIG_RETPOLINE && CONFIG_STACK_VALIDATION */ | 514 | #endif /* CONFIG_RETPOLINE && CONFIG_OBJTOOL */ |
| 515 | 515 | ||
| 516 | #ifdef CONFIG_X86_KERNEL_IBT | 516 | #ifdef CONFIG_X86_KERNEL_IBT |
| 517 | 517 | ||
| @@ -109,7 +109,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, · 108 unmodified lines | |||
| 109 | #endif | 109 | #endif |
| 110 | 110 | ||
| 111 | /* Unreachable code */ | 111 | /* Unreachable code */ |
| 112 | #ifdef CONFIG_STACK_VALIDATION | 112 | #ifdef CONFIG_OBJTOOL |
| 113 | /* | 113 | /* |
| 114 | * These macros help objtool understand GCC code flow for unreachable code. | 114 | * These macros help objtool understand GCC code flow for unreachable code. |
| 115 | * The __COUNTER__ based labels are a hack to make each instance of the macros | 115 | * 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, · 12 unmodified lines | |||
| 128 | /* Annotate a C jump table to allow objtool to follow the code flow */ | 128 | /* Annotate a C jump table to allow objtool to follow the code flow */ |
| 129 | #define __annotate_jump_table __section(".rodata..c_jump_table") | 129 | #define __annotate_jump_table __section(".rodata..c_jump_table") |
| 130 | 130 | ||
| 131 | #else | 131 | #else /* !CONFIG_OBJTOOL */ |
| 132 | #define annotate_unreachable() | 132 | #define annotate_unreachable() |
| 133 | #define __annotate_jump_table | 133 | #define __annotate_jump_table |
| 134 | #endif | 134 | #endif /* CONFIG_OBJTOOL */ |
| 135 | 135 | ||
| 136 | #ifndef unreachable | 136 | #ifndef unreachable |
| 137 | # define unreachable() do { \ | 137 | # define unreachable() do { \ |
| @@ -2,7 +2,7 @@ · 1 unmodified line | |||
| 2 | #ifndef __LINUX_INSTRUMENTATION_H | 2 | #ifndef __LINUX_INSTRUMENTATION_H |
| 3 | #define __LINUX_INSTRUMENTATION_H | 3 | #define __LINUX_INSTRUMENTATION_H |
| 4 | 4 | ||
| 5 | #if defined(CONFIG_DEBUG_ENTRY) && defined(CONFIG_STACK_VALIDATION) | 5 | #ifdef CONFIG_VMLINUX_VALIDATION |
| 6 | 6 | ||
| 7 | #include <linux/stringify.h> | 7 | #include <linux/stringify.h> |
| 8 | 8 | ||
| @@ -53,9 +53,9 @@ · 44 unmodified lines | |||
| 53 | ".popsection\n\t" : : "i" (c)); \ | 53 | ".popsection\n\t" : : "i" (c)); \ |
| 54 | }) | 54 | }) |
| 55 | #define instrumentation_end() __instrumentation_end(__COUNTER__) | 55 | #define instrumentation_end() __instrumentation_end(__COUNTER__) |
| 56 | #else | 56 | #else /* !CONFIG_VMLINUX_VALIDATION */ |
| 57 | # define instrumentation_begin() do { } while(0) | 57 | # define instrumentation_begin() do { } while(0) |
| 58 | # define instrumentation_end() do { } while(0) | 58 | # define instrumentation_end() do { } while(0) |
| 59 | #endif | 59 | #endif /* CONFIG_VMLINUX_VALIDATION */ |
| 60 | 60 | ||
| 61 | #endif /* __LINUX_INSTRUMENTATION_H */ | 61 | #endif /* __LINUX_INSTRUMENTATION_H */ |
| @@ -38,7 +38,7 @@ struct unwind_hint { · 37 unmodified lines | |||
| 38 | #define UNWIND_HINT_TYPE_REGS_PARTIAL 2 | 38 | #define UNWIND_HINT_TYPE_REGS_PARTIAL 2 |
| 39 | #define UNWIND_HINT_TYPE_FUNC 3 | 39 | #define UNWIND_HINT_TYPE_FUNC 3 |
| 40 | 40 | ||
| 41 | #ifdef CONFIG_STACK_VALIDATION | 41 | #ifdef CONFIG_OBJTOOL |
| 42 | 42 | ||
| 43 | #ifndef __ASSEMBLY__ | 43 | #ifndef __ASSEMBLY__ |
| 44 | 44 | ||
| @@ -157,7 +157,7 @@ struct unwind_hint { · 112 unmodified lines | |||
| 157 | 157 | ||
| 158 | #endif /* __ASSEMBLY__ */ | 158 | #endif /* __ASSEMBLY__ */ |
| 159 | 159 | ||
| 160 | #else /* !CONFIG_STACK_VALIDATION */ | 160 | #else /* !CONFIG_OBJTOOL */ |
| 161 | 161 | ||
| 162 | #ifndef __ASSEMBLY__ | 162 | #ifndef __ASSEMBLY__ |
| 163 | 163 | ||
| @@ -179,6 +179,6 @@ struct unwind_hint { · 15 unmodified lines | |||
| 179 | .endm | 179 | .endm |
| 180 | #endif | 180 | #endif |
| 181 | 181 | ||
| 182 | #endif /* CONFIG_STACK_VALIDATION */ | 182 | #endif /* CONFIG_OBJTOOL */ |
| 183 | 183 | ||
| 184 | #endif /* _LINUX_OBJTOOL_H */ | 184 | #endif /* _LINUX_OBJTOOL_H */ |
| @@ -728,6 +728,7 @@ config FTRACE_MCOUNT_USE_OBJTOOL · 727 unmodified lines | |||
| 728 | depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY | 728 | depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY |
| 729 | depends on !FTRACE_MCOUNT_USE_CC | 729 | depends on !FTRACE_MCOUNT_USE_CC |
| 730 | depends on FTRACE_MCOUNT_RECORD | 730 | depends on FTRACE_MCOUNT_RECORD |
| 731 | select OBJTOOL | ||
| 731 | 732 | ||
| 732 | config FTRACE_MCOUNT_USE_RECORDMCOUNT | 733 | config FTRACE_MCOUNT_USE_RECORDMCOUNT |
| 733 | def_bool y | 734 | def_bool y |
| @@ -485,24 +485,25 @@ config FRAME_POINTER · 484 unmodified lines | |||
| 485 | larger and slower, but it gives very useful debugging information | 485 | larger and slower, but it gives very useful debugging information |
| 486 | in case of kernel bugs. (precise oopses/stacktraces/warnings) | 486 | in case of kernel bugs. (precise oopses/stacktraces/warnings) |
| 487 | 487 | ||
| 488 | config OBJTOOL | ||
| 489 | bool | ||
| 490 | |||
| 488 | config STACK_VALIDATION | 491 | config STACK_VALIDATION |
| 489 | bool "Compile-time stack metadata validation" | 492 | bool "Compile-time stack metadata validation" |
| 490 | depends on HAVE_STACK_VALIDATION | 493 | depends on HAVE_STACK_VALIDATION && UNWINDER_FRAME_POINTER |
| 494 | select OBJTOOL | ||
| 491 | default n | 495 | default n |
| 492 | help | 496 | help |
| 493 | Add compile-time checks to validate stack metadata, including frame | 497 | Validate frame pointer rules at compile-time. This helps ensure that |
| 494 | pointers (if CONFIG_FRAME_POINTER is enabled). This helps ensure | 498 | runtime stack traces are more reliable. |
| 495 | that runtime stack traces are more reliable. | ||
| 496 | |||
| 497 | This is also a prerequisite for generation of ORC unwind data, which | ||
| 498 | is needed for CONFIG_UNWINDER_ORC. | ||
| 499 | 499 | ||
| 500 | For more information, see | 500 | For more information, see |
| 501 | tools/objtool/Documentation/stack-validation.txt. | 501 | tools/objtool/Documentation/stack-validation.txt. |
| 502 | 502 | ||
| 503 | config VMLINUX_VALIDATION | 503 | config VMLINUX_VALIDATION |
| 504 | bool | 504 | bool |
| 505 | depends on STACK_VALIDATION && DEBUG_ENTRY | 505 | depends on HAVE_OBJTOOL && DEBUG_ENTRY |
| 506 | select OBJTOOL | ||
| 506 | default y | 507 | default y |
| 507 | 508 | ||
| 508 | config VMLINUX_MAP | 509 | config VMLINUX_MAP |
| @@ -2035,10 +2036,11 @@ config KCOV · 1526 unmodified lines | |||
| 2035 | bool "Code coverage for fuzzing" | 2036 | bool "Code coverage for fuzzing" |
| 2036 | depends on ARCH_HAS_KCOV | 2037 | depends on ARCH_HAS_KCOV |
| 2037 | depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS | 2038 | depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS |
| 2038 | depends on !ARCH_WANTS_NO_INSTR || STACK_VALIDATION || \ | 2039 | depends on !ARCH_WANTS_NO_INSTR || HAVE_OBJTOOL || \ |
| 2039 | GCC_VERSION >= 120000 || CLANG_VERSION >= 130000 | 2040 | GCC_VERSION >= 120000 || CLANG_VERSION >= 130000 |
| 2040 | select DEBUG_FS | 2041 | select DEBUG_FS |
| 2041 | select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC | 2042 | select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC |
| 2043 | select OBJTOOL if HAVE_OBJTOOL | ||
| 2042 | help | 2044 | help |
| 2043 | KCOV exposes kernel code coverage information in a form suitable | 2045 | KCOV exposes kernel code coverage information in a form suitable |
| 2044 | for coverage-guided fuzzing (randomized testing). | 2046 | for coverage-guided fuzzing (randomized testing). |
| @@ -187,7 +187,8 @@ config KCSAN_WEAK_MEMORY · 186 unmodified lines | |||
| 187 | # We can either let objtool nop __tsan_func_{entry,exit}() and builtin | 187 | # We can either let objtool nop __tsan_func_{entry,exit}() and builtin |
| 188 | # atomics instrumentation in .noinstr.text, or use a compiler that can | 188 | # atomics instrumentation in .noinstr.text, or use a compiler that can |
| 189 | # implement __no_kcsan to really remove all instrumentation. | 189 | # implement __no_kcsan to really remove all instrumentation. |
| 190 | depends on STACK_VALIDATION || CC_IS_GCC || CLANG_VERSION >= 140000 | 190 | depends on HAVE_OBJTOOL || CC_IS_GCC || CLANG_VERSION >= 140000 |
| 191 | select OBJTOOL if HAVE_OBJTOOL | ||
| 191 | help | 192 | help |
| 192 | Enable support for modeling a subset of weak memory, which allows | 193 | Enable support for modeling a subset of weak memory, which allows |
| 193 | detecting a subset of data races due to missing memory barriers. | 194 | detecting a subset of data races due to missing memory barriers. |
| @@ -94,7 +94,7 @@ config UBSAN_UNREACHABLE · 93 unmodified lines | |||
| 94 | bool "Perform checking for unreachable code" | 94 | bool "Perform checking for unreachable code" |
| 95 | # objtool already handles unreachable checking and gets angry about | 95 | # objtool already handles unreachable checking and gets angry about |
| 96 | # seeing UBSan instrumentation located in unreachable places. | 96 | # seeing UBSan instrumentation located in unreachable places. |
| 97 | depends on !STACK_VALIDATION | 97 | depends on !(OBJTOOL && (STACK_VALIDATION || UNWINDER_ORC || X86_SMAP)) |
| 98 | depends on $(cc-option,-fsanitize=unreachable) | 98 | depends on $(cc-option,-fsanitize=unreachable) |
| 99 | help | 99 | help |
| 100 | This option enables -fsanitize=unreachable which checks for control | 100 | This option enables -fsanitize=unreachable which checks for control |
| @@ -222,7 +222,7 @@ cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), · 221 unmodified lines | |||
| 222 | $(sub_cmd_record_mcount)) | 222 | $(sub_cmd_record_mcount)) |
| 223 | endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT | 223 | endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT |
| 224 | 224 | ||
| 225 | ifdef CONFIG_STACK_VALIDATION | 225 | ifdef CONFIG_OBJTOOL |
| 226 | 226 | ||
| 227 | objtool := $(objtree)/tools/objtool/objtool | 227 | objtool := $(objtree)/tools/objtool/objtool |
| 228 | 228 | ||
| @@ -241,7 +241,7 @@ objtool_args = \ · 12 unmodified lines | |||
| 241 | cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@) | 241 | cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@) |
| 242 | cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd) | 242 | cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd) |
| 243 | 243 | ||
| 244 | endif # CONFIG_STACK_VALIDATION | 244 | endif # CONFIG_OBJTOOL |
| 245 | 245 | ||
| 246 | ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),) | 246 | ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),) |
| 247 | 247 | ||
| @@ -108,8 +108,11 @@ objtool_link() · 107 unmodified lines | |||
| 108 | local objtoolcmd; | 108 | local objtoolcmd; |
| 109 | local objtoolopt; | 109 | local objtoolopt; |
| 110 | 110 | ||
| 111 | if is_enabled CONFIG_STACK_VALIDATION && \ | 111 | if ! is_enabled CONFIG_OBJTOOL; then |
| 112 | ( is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT ); then | 112 | return; |
| 113 | fi | ||
| 114 | |||
| 115 | if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; then | ||
| 113 | 116 | ||
| 114 | # Don't perform vmlinux validation unless explicitly requested, | 117 | # Don't perform vmlinux validation unless explicitly requested, |
| 115 | # but run objtool on vmlinux.o now that we have an object file. | 118 | # but run objtool on vmlinux.o now that we have an object file. |
| @@ -126,10 +129,23 @@ objtool_link() · 10 unmodified lines | |||
| 126 | objtoolopt="${objtoolopt} --orc" | 129 | objtoolopt="${objtoolopt} --orc" |
| 127 | fi | 130 | fi |
| 128 | 131 | ||
| 132 | if is_enabled CONFIG_RETPOLINE; then | ||
| 133 | objtoolopt="${objtoolopt} --retpoline" | ||
| 134 | fi | ||
| 135 | |||
| 136 | if is_enabled CONFIG_SLS; then | ||
| 137 | objtoolopt="${objtoolopt} --sls" | ||
| 138 | fi | ||
| 139 | |||
| 129 | if is_enabled CONFIG_STACK_VALIDATION; then | 140 | if is_enabled CONFIG_STACK_VALIDATION; then |
| 130 | objtoolopt="${objtoolopt} --stackval" | 141 | objtoolopt="${objtoolopt} --stackval" |
| 131 | fi | 142 | fi |
| 132 | 143 | ||
| 144 | if is_enabled CONFIG_X86_SMAP; then | ||
| 145 | objtoolopt="${objtoolopt} --uaccess" | ||
| 146 | fi | ||
| 147 | |||
| 148 | |||
| 133 | objtoolopt="${objtoolopt} --lto" | 149 | objtoolopt="${objtoolopt} --lto" |
| 134 | fi | 150 | fi |
| 135 | 151 | ||
| @@ -139,18 +155,6 @@ objtool_link() · 3 unmodified lines | |||
| 139 | 155 | ||
| 140 | if [ -n "${objtoolopt}" ]; then | 156 | if [ -n "${objtoolopt}" ]; then |
| 141 | 157 | ||
| 142 | if is_enabled CONFIG_RETPOLINE; then | ||
| 143 | objtoolopt="${objtoolopt} --retpoline" | ||
| 144 | fi | ||
| 145 | |||
| 146 | if is_enabled CONFIG_SLS; then | ||
| 147 | objtoolopt="${objtoolopt} --sls" | ||
| 148 | fi | ||
| 149 | |||
| 150 | if is_enabled CONFIG_X86_SMAP; then | ||
| 151 | objtoolopt="${objtoolopt} --uaccess" | ||
| 152 | fi | ||
| 153 | |||
| 154 | if ! is_enabled CONFIG_FRAME_POINTER; then | 158 | if ! is_enabled CONFIG_FRAME_POINTER; then |
| 155 | objtoolopt="${objtoolopt} --no-fp" | 159 | objtoolopt="${objtoolopt} --no-fp" |
| 156 | fi | 160 | fi |
| @@ -67,7 +67,7 @@ deploy_kernel_headers () { · 66 unmodified lines | |||
| 67 | ) > debian/hdrsrcfiles | 67 | ) > debian/hdrsrcfiles |
| 68 | 68 | ||
| 69 | { | 69 | { |
| 70 | if is_enabled CONFIG_STACK_VALIDATION; then | 70 | if is_enabled CONFIG_OBJTOOL; then |
| 71 | echo tools/objtool/objtool | 71 | echo tools/objtool/objtool |
| 72 | fi | 72 | fi |
| 73 | 73 | ||
| @@ -38,7 +38,7 @@ struct unwind_hint { · 37 unmodified lines | |||
| 38 | #define UNWIND_HINT_TYPE_REGS_PARTIAL 2 | 38 | #define UNWIND_HINT_TYPE_REGS_PARTIAL 2 |
| 39 | #define UNWIND_HINT_TYPE_FUNC 3 | 39 | #define UNWIND_HINT_TYPE_FUNC 3 |
| 40 | 40 | ||
| 41 | #ifdef CONFIG_STACK_VALIDATION | 41 | #ifdef CONFIG_OBJTOOL |
| 42 | 42 | ||
| 43 | #ifndef __ASSEMBLY__ | 43 | #ifndef __ASSEMBLY__ |
| 44 | 44 | ||
| @@ -157,7 +157,7 @@ struct unwind_hint { · 112 unmodified lines | |||
| 157 | 157 | ||
| 158 | #endif /* __ASSEMBLY__ */ | 158 | #endif /* __ASSEMBLY__ */ |
| 159 | 159 | ||
| 160 | #else /* !CONFIG_STACK_VALIDATION */ | 160 | #else /* !CONFIG_OBJTOOL */ |
| 161 | 161 | ||
| 162 | #ifndef __ASSEMBLY__ | 162 | #ifndef __ASSEMBLY__ |
| 163 | 163 | ||
| @@ -179,6 +179,6 @@ struct unwind_hint { · 15 unmodified lines | |||
| 179 | .endm | 179 | .endm |
| 180 | #endif | 180 | #endif |
| 181 | 181 | ||
| 182 | #endif /* CONFIG_STACK_VALIDATION */ | 182 | #endif /* CONFIG_OBJTOOL */ |
| 183 | 183 | ||
| 184 | #endif /* _LINUX_OBJTOOL_H */ | 184 | #endif /* _LINUX_OBJTOOL_H */ |