Skip to content

Commit 92b71be

Browse files
committed
Merge tag 'objtool-urgent-2025-04-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool fixes from Ingo Molnar: "These are objtool fixes and updates by Josh Poimboeuf, centered around the fallout from the new CONFIG_OBJTOOL_WERROR=y feature, which, despite its default-off nature, increased the profile/impact of objtool warnings: - Improve error handling and the presentation of warnings/errors - Revert the new summary warning line that some test-bot tools interpreted as new regressions - Fix a number of objtool warnings in various drivers, core kernel code and architecture code. About half of them are potential problems related to out-of-bounds accesses or potential undefined behavior, the other half are additional objtool annotations - Update objtool to latest (known) compiler quirks and objtool bugs triggered by compiler code generation - Misc fixes" * tag 'objtool-urgent-2025-04-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (36 commits) objtool/loongarch: Add unwind hints in prepare_frametrace() rcu-tasks: Always inline rcu_irq_work_resched() context_tracking: Always inline ct_{nmi,irq}_{enter,exit}() sched/smt: Always inline sched_smt_active() objtool: Fix verbose disassembly if CROSS_COMPILE isn't set objtool: Change "warning:" to "error: " for fatal errors objtool: Always fail on fatal errors Revert "objtool: Increase per-function WARN_FUNC() rate limit" objtool: Append "()" to function name in "unexpected end of section" warning objtool: Ignore end-of-section jumps for KCOV/GCOV objtool: Silence more KCOV warnings, part 2 objtool, drm/vmwgfx: Don't ignore vmw_send_msg() for ORC objtool: Fix STACK_FRAME_NON_STANDARD for cold subfunctions objtool: Fix segfault in ignore_unreachable_insn() objtool: Fix NULL printf() '%s' argument in builtin-check.c:save_argv() objtool, lkdtm: Obfuscate the do_nothing() pointer objtool, regulator: rk808: Remove potential undefined behavior in rk806_set_mode_dcdc() objtool, ASoC: codecs: wcd934x: Remove potential undefined behavior in wcd934x_slim_irq_handler() objtool, Input: cyapa - Remove undefined behavior in cyapa_update_fw_store() objtool, panic: Disable SMAP in __stack_chk_fail() ...
2 parents af54a3a + 7c97739 commit 92b71be

File tree

39 files changed

+679
-650
lines changed

39 files changed

+679
-650
lines changed

arch/loongarch/include/asm/stacktrace.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <asm/asm.h>
99
#include <asm/ptrace.h>
1010
#include <asm/loongarch.h>
11+
#include <asm/unwind_hints.h>
1112
#include <linux/stringify.h>
1213

1314
enum stack_type {
@@ -43,6 +44,7 @@ int get_stack_info(unsigned long stack, struct task_struct *task, struct stack_i
4344
static __always_inline void prepare_frametrace(struct pt_regs *regs)
4445
{
4546
__asm__ __volatile__(
47+
UNWIND_HINT_SAVE
4648
/* Save $ra */
4749
STORE_ONE_REG(1)
4850
/* Use $ra to save PC */
@@ -80,6 +82,7 @@ static __always_inline void prepare_frametrace(struct pt_regs *regs)
8082
STORE_ONE_REG(29)
8183
STORE_ONE_REG(30)
8284
STORE_ONE_REG(31)
85+
UNWIND_HINT_RESTORE
8386
: "=m" (regs->csr_era)
8487
: "r" (regs->regs)
8588
: "memory");

arch/loongarch/include/asm/unwind_hints.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_CALL
2424
.endm
2525

26-
#endif /* __ASSEMBLY__ */
26+
#else /* !__ASSEMBLY__ */
27+
28+
#define UNWIND_HINT_SAVE \
29+
UNWIND_HINT(UNWIND_HINT_TYPE_SAVE, 0, 0, 0)
30+
31+
#define UNWIND_HINT_RESTORE \
32+
UNWIND_HINT(UNWIND_HINT_TYPE_RESTORE, 0, 0, 0)
33+
34+
#endif /* !__ASSEMBLY__ */
2735

2836
#endif /* _ASM_LOONGARCH_UNWIND_HINTS_H */

arch/x86/include/asm/arch_hweight.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ static __always_inline unsigned int __arch_hweight32(unsigned int w)
1616
{
1717
unsigned int res;
1818

19-
asm_inline (ALTERNATIVE("call __sw_hweight32",
19+
asm_inline (ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
20+
"call __sw_hweight32",
2021
"popcntl %[val], %[cnt]", X86_FEATURE_POPCNT)
2122
: [cnt] "=" REG_OUT (res), ASM_CALL_CONSTRAINT
2223
: [val] REG_IN (w));
@@ -45,7 +46,8 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
4546
{
4647
unsigned long res;
4748

48-
asm_inline (ALTERNATIVE("call __sw_hweight64",
49+
asm_inline (ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
50+
"call __sw_hweight64",
4951
"popcntq %[val], %[cnt]", X86_FEATURE_POPCNT)
5052
: [cnt] "=" REG_OUT (res), ASM_CALL_CONSTRAINT
5153
: [val] REG_IN (w));

arch/x86/include/asm/smap.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,32 @@
1616
#ifdef __ASSEMBLER__
1717

1818
#define ASM_CLAC \
19-
ALTERNATIVE "", "clac", X86_FEATURE_SMAP
19+
ALTERNATIVE __stringify(ANNOTATE_IGNORE_ALTERNATIVE), "clac", X86_FEATURE_SMAP
2020

2121
#define ASM_STAC \
22-
ALTERNATIVE "", "stac", X86_FEATURE_SMAP
22+
ALTERNATIVE __stringify(ANNOTATE_IGNORE_ALTERNATIVE), "stac", X86_FEATURE_SMAP
2323

2424
#else /* __ASSEMBLER__ */
2525

2626
static __always_inline void clac(void)
2727
{
2828
/* Note: a barrier is implicit in alternative() */
29-
alternative("", "clac", X86_FEATURE_SMAP);
29+
alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP);
3030
}
3131

3232
static __always_inline void stac(void)
3333
{
3434
/* Note: a barrier is implicit in alternative() */
35-
alternative("", "stac", X86_FEATURE_SMAP);
35+
alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP);
3636
}
3737

3838
static __always_inline unsigned long smap_save(void)
3939
{
4040
unsigned long flags;
4141

4242
asm volatile ("# smap_save\n\t"
43-
ALTERNATIVE("", "pushf; pop %0; " "clac" "\n\t",
43+
ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
44+
"", "pushf; pop %0; clac",
4445
X86_FEATURE_SMAP)
4546
: "=rm" (flags) : : "memory", "cc");
4647

@@ -50,16 +51,22 @@ static __always_inline unsigned long smap_save(void)
5051
static __always_inline void smap_restore(unsigned long flags)
5152
{
5253
asm volatile ("# smap_restore\n\t"
53-
ALTERNATIVE("", "push %0; popf\n\t",
54+
ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
55+
"", "push %0; popf",
5456
X86_FEATURE_SMAP)
5557
: : "g" (flags) : "memory", "cc");
5658
}
5759

5860
/* These macros can be used in asm() statements */
5961
#define ASM_CLAC \
60-
ALTERNATIVE("", "clac", X86_FEATURE_SMAP)
62+
ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP)
6163
#define ASM_STAC \
62-
ALTERNATIVE("", "stac", X86_FEATURE_SMAP)
64+
ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP)
65+
66+
#define ASM_CLAC_UNSAFE \
67+
ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "clac", X86_FEATURE_SMAP)
68+
#define ASM_STAC_UNSAFE \
69+
ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "stac", X86_FEATURE_SMAP)
6370

6471
#endif /* __ASSEMBLER__ */
6572

arch/x86/include/asm/xen/hypercall.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,12 @@ static __always_inline void __xen_stac(void)
231231
* Suppress objtool seeing the STAC/CLAC and getting confused about it
232232
* calling random code with AC=1.
233233
*/
234-
asm volatile(ANNOTATE_IGNORE_ALTERNATIVE
235-
ASM_STAC ::: "memory", "flags");
234+
asm volatile(ASM_STAC_UNSAFE ::: "memory", "flags");
236235
}
237236

238237
static __always_inline void __xen_clac(void)
239238
{
240-
asm volatile(ANNOTATE_IGNORE_ALTERNATIVE
241-
ASM_CLAC ::: "memory", "flags");
239+
asm volatile(ASM_CLAC_UNSAFE ::: "memory", "flags");
242240
}
243241

244242
static inline long

drivers/gpu/drm/vmwgfx/vmwgfx_msg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int vmw_send_msg(struct rpc_channel *channel, const char *msg)
289289

290290
return -EINVAL;
291291
}
292-
STACK_FRAME_NON_STANDARD(vmw_send_msg);
292+
STACK_FRAME_NON_STANDARD_FP(vmw_send_msg);
293293

294294

295295
/**

drivers/input/mouse/cyapa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,8 @@ static ssize_t cyapa_update_fw_store(struct device *dev,
10801080
char fw_name[NAME_MAX];
10811081
int ret, error;
10821082

1083-
if (count >= NAME_MAX) {
1084-
dev_err(dev, "File name too long\n");
1083+
if (!count || count >= NAME_MAX) {
1084+
dev_err(dev, "Bad file name size\n");
10851085
return -EINVAL;
10861086
}
10871087

drivers/media/dvb-frontends/dib8000.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2701,8 +2701,11 @@ static void dib8000_set_dds(struct dib8000_state *state, s32 offset_khz)
27012701
u8 ratio;
27022702

27032703
if (state->revision == 0x8090) {
2704+
u32 internal = dib8000_read32(state, 23) / 1000;
2705+
27042706
ratio = 4;
2705-
unit_khz_dds_val = (1<<26) / (dib8000_read32(state, 23) / 1000);
2707+
2708+
unit_khz_dds_val = (1<<26) / (internal ?: 1);
27062709
if (offset_khz < 0)
27072710
dds = (1 << 26) - (abs_offset_khz * unit_khz_dds_val);
27082711
else

drivers/misc/lkdtm/perms.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ static const unsigned long rodata = 0xAA55AA55;
2828
/* This is marked __ro_after_init, so it should ultimately be .rodata. */
2929
static unsigned long ro_after_init __ro_after_init = 0x55AA5500;
3030

31+
/*
32+
* This is a pointer to do_nothing() which is initialized at runtime rather
33+
* than build time to avoid objtool IBT validation warnings caused by an
34+
* inlined unrolled memcpy() in execute_location().
35+
*/
36+
static void __ro_after_init *do_nothing_ptr;
37+
3138
/*
3239
* This just returns to the caller. It is designed to be copied into
3340
* non-executable memory regions.
@@ -65,13 +72,12 @@ static noinline __nocfi void execute_location(void *dst, bool write)
6572
{
6673
void (*func)(void);
6774
func_desc_t fdesc;
68-
void *do_nothing_text = dereference_function_descriptor(do_nothing);
6975

70-
pr_info("attempting ok execution at %px\n", do_nothing_text);
76+
pr_info("attempting ok execution at %px\n", do_nothing_ptr);
7177
do_nothing();
7278

7379
if (write == CODE_WRITE) {
74-
memcpy(dst, do_nothing_text, EXEC_SIZE);
80+
memcpy(dst, do_nothing_ptr, EXEC_SIZE);
7581
flush_icache_range((unsigned long)dst,
7682
(unsigned long)dst + EXEC_SIZE);
7783
}
@@ -267,6 +273,8 @@ static void lkdtm_ACCESS_NULL(void)
267273

268274
void __init lkdtm_perms_init(void)
269275
{
276+
do_nothing_ptr = dereference_function_descriptor(do_nothing);
277+
270278
/* Make sure we can write to __ro_after_init values during __init */
271279
ro_after_init |= 0xAA;
272280
}

drivers/nvme/target/debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int nvmet_ctrl_state_show(struct seq_file *m, void *p)
7878
bool sep = false;
7979
int i;
8080

81-
for (i = 0; i < 7; i++) {
81+
for (i = 0; i < ARRAY_SIZE(csts_state_names); i++) {
8282
int state = BIT(i);
8383

8484
if (!(ctrl->csts & state))

0 commit comments

Comments
 (0)