Skip to content

Commit 44688ff

Browse files
committed
Merge tag 'objtool-urgent-2022-06-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool fixes from Thomas Gleixner: - Handle __ubsan_handle_builtin_unreachable() correctly and treat it as noreturn - Allow architectures to select uaccess validation - Use the non-instrumented bit test for test_cpu_has() to prevent escape from non-instrumentable regions - Use arch_ prefixed atomics for JUMP_LABEL=n builds to prevent escape from non-instrumentable regions - Mark a few tiny inline as __always_inline to prevent GCC from bringing them out of line and instrumenting them - Mark the empty stub context_tracking_enabled() as always inline as GCC brings them out of line and instruments the empty shell - Annotate ex_handler_msr_mce() as dead end * tag 'objtool-urgent-2022-06-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/extable: Annotate ex_handler_msr_mce() as a dead end context_tracking: Always inline empty stubs x86: Always inline on_thread_stack() and current_top_of_stack() jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds x86/cpu: Elide KCSAN for cpu_has() and friends objtool: Mark __ubsan_handle_builtin_unreachable() as noreturn objtool: Add CONFIG_HAVE_UACCESS_VALIDATION
2 parents b2c9a83 + 2028a25 commit 44688ff

File tree

9 files changed

+24
-13
lines changed

9 files changed

+24
-13
lines changed

arch/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,10 @@ config HAVE_NOINSTR_HACK
10481048
config HAVE_NOINSTR_VALIDATION
10491049
bool
10501050

1051+
config HAVE_UACCESS_VALIDATION
1052+
bool
1053+
select OBJTOOL
1054+
10511055
config HAVE_STACK_VALIDATION
10521056
bool
10531057
help

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ config X86
258258
select HAVE_PREEMPT_DYNAMIC_CALL
259259
select HAVE_RSEQ
260260
select HAVE_SYSCALL_TRACEPOINTS
261+
select HAVE_UACCESS_VALIDATION if HAVE_OBJTOOL
261262
select HAVE_UNSTABLE_SCHED_CLOCK
262263
select HAVE_USER_RETURN_NOTIFIER
263264
select HAVE_GENERIC_VDSO

arch/x86/include/asm/cpufeature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extern const char * const x86_power_flags[32];
5454
extern const char * const x86_bug_flags[NBUGINTS*32];
5555

5656
#define test_cpu_cap(c, bit) \
57-
test_bit(bit, (unsigned long *)((c)->x86_capability))
57+
arch_test_bit(bit, (unsigned long *)((c)->x86_capability))
5858

5959
/*
6060
* There are 32 bits/features in each mask word. The high bits

arch/x86/include/asm/extable.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ extern int ex_get_fixup_type(unsigned long ip);
4242
extern void early_fixup_exception(struct pt_regs *regs, int trapnr);
4343

4444
#ifdef CONFIG_X86_MCE
45-
extern void ex_handler_msr_mce(struct pt_regs *regs, bool wrmsr);
45+
extern void __noreturn ex_handler_msr_mce(struct pt_regs *regs, bool wrmsr);
4646
#else
47-
static inline void ex_handler_msr_mce(struct pt_regs *regs, bool wrmsr) { }
47+
static inline void __noreturn ex_handler_msr_mce(struct pt_regs *regs, bool wrmsr)
48+
{
49+
for (;;)
50+
cpu_relax();
51+
}
4852
#endif
4953

5054
#if defined(CONFIG_BPF_JIT) && defined(CONFIG_X86_64)

arch/x86/include/asm/processor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ static __always_inline void native_swapgs(void)
559559
#endif
560560
}
561561

562-
static inline unsigned long current_top_of_stack(void)
562+
static __always_inline unsigned long current_top_of_stack(void)
563563
{
564564
/*
565565
* We can't read directly from tss.sp0: sp0 on x86_32 is special in
@@ -569,7 +569,7 @@ static inline unsigned long current_top_of_stack(void)
569569
return this_cpu_read_stable(cpu_current_top_of_stack);
570570
}
571571

572-
static inline bool on_thread_stack(void)
572+
static __always_inline bool on_thread_stack(void)
573573
{
574574
return (unsigned long)(current_top_of_stack() -
575575
current_stack_pointer) < THREAD_SIZE;

include/linux/context_tracking_state.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ static __always_inline bool context_tracking_in_user(void)
4646
return __this_cpu_read(context_tracking.state) == CONTEXT_USER;
4747
}
4848
#else
49-
static inline bool context_tracking_in_user(void) { return false; }
50-
static inline bool context_tracking_enabled(void) { return false; }
51-
static inline bool context_tracking_enabled_cpu(int cpu) { return false; }
52-
static inline bool context_tracking_enabled_this_cpu(void) { return false; }
49+
static __always_inline bool context_tracking_in_user(void) { return false; }
50+
static __always_inline bool context_tracking_enabled(void) { return false; }
51+
static __always_inline bool context_tracking_enabled_cpu(int cpu) { return false; }
52+
static __always_inline bool context_tracking_enabled_this_cpu(void) { return false; }
5353
#endif /* CONFIG_CONTEXT_TRACKING */
5454

5555
#endif

include/linux/jump_label.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ extern void static_key_disable_cpuslocked(struct static_key *key);
256256
#include <linux/atomic.h>
257257
#include <linux/bug.h>
258258

259-
static inline int static_key_count(struct static_key *key)
259+
static __always_inline int static_key_count(struct static_key *key)
260260
{
261-
return atomic_read(&key->enabled);
261+
return arch_atomic_read(&key->enabled);
262262
}
263263

264264
static __always_inline void jump_label_init(void)

scripts/Makefile.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ objtool_args = \
239239
$(if $(CONFIG_SLS), --sls) \
240240
$(if $(CONFIG_STACK_VALIDATION), --stackval) \
241241
$(if $(CONFIG_HAVE_STATIC_CALL_INLINE), --static-call) \
242-
--uaccess \
242+
$(if $(CONFIG_HAVE_UACCESS_VALIDATION), --uaccess) \
243243
$(if $(delay-objtool), --link) \
244244
$(if $(part-of-module), --module) \
245245
$(if $(CONFIG_GCOV_KERNEL), --no-unreachable)

tools/objtool/check.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
185185
"do_group_exit",
186186
"stop_this_cpu",
187187
"__invalid_creds",
188-
"cpu_startup_entry",
188+
"cpu_startup_entry",
189+
"__ubsan_handle_builtin_unreachable",
190+
"ex_handler_msr_mce",
189191
};
190192

191193
if (!func)

0 commit comments

Comments
 (0)