Skip to content

Commit 5920da4

Browse files
committed
Merge tag 'x86-urgent-2026-03-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: - Fix speculative safety in fred_extint() - Fix __WARN_printf() trap in early_fixup_exception() - Fix clang-build boot bug for unusual alignments, triggered by CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B=y - Replace the final few __ASSEMBLY__ stragglers that snuck in lately into non-UAPI x86 headers and use __ASSEMBLER__ consistently (again) * tag 'x86-urgent-2026-03-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/headers: Replace __ASSEMBLY__ stragglers with __ASSEMBLER__ x86/cfi: Fix CFI rewrite for odd alignments x86/bug: Handle __WARN_printf() trap in early_fixup_exception() x86/fred: Correct speculative safety in fred_extint()
2 parents f6542af + 237dc6a commit 5920da4

File tree

12 files changed

+50
-42
lines changed

12 files changed

+50
-42
lines changed

arch/x86/entry/entry_fred.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ void __init fred_complete_exception_setup(void)
160160
static noinstr void fred_extint(struct pt_regs *regs)
161161
{
162162
unsigned int vector = regs->fred_ss.vector;
163-
unsigned int index = array_index_nospec(vector - FIRST_SYSTEM_VECTOR,
164-
NR_SYSTEM_VECTORS);
165163

166164
if (WARN_ON_ONCE(vector < FIRST_EXTERNAL_VECTOR))
167165
return;
@@ -170,7 +168,8 @@ static noinstr void fred_extint(struct pt_regs *regs)
170168
irqentry_state_t state = irqentry_enter(regs);
171169

172170
instrumentation_begin();
173-
sysvec_table[index](regs);
171+
sysvec_table[array_index_nospec(vector - FIRST_SYSTEM_VECTOR,
172+
NR_SYSTEM_VECTORS)](regs);
174173
instrumentation_end();
175174
irqentry_exit(regs, state);
176175
} else {

arch/x86/include/asm/bug.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <linux/objtool.h>
88
#include <asm/asm.h>
99

10-
#ifndef __ASSEMBLY__
10+
#ifndef __ASSEMBLER__
1111
struct bug_entry;
1212
extern void __WARN_trap(struct bug_entry *bug, ...);
1313
#endif
@@ -137,7 +137,7 @@ do { \
137137

138138
#ifdef HAVE_ARCH_BUG_FORMAT_ARGS
139139

140-
#ifndef __ASSEMBLY__
140+
#ifndef __ASSEMBLER__
141141
#include <linux/static_call_types.h>
142142
DECLARE_STATIC_CALL(WARN_trap, __WARN_trap);
143143

@@ -153,7 +153,7 @@ struct arch_va_list {
153153
struct sysv_va_list args;
154154
};
155155
extern void *__warn_args(struct arch_va_list *args, struct pt_regs *regs);
156-
#endif /* __ASSEMBLY__ */
156+
#endif /* __ASSEMBLER__ */
157157

158158
#define __WARN_bug_entry(flags, format) ({ \
159159
struct bug_entry *bug; \

arch/x86/include/asm/cfi.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ extern bhi_thunk __bhi_args_end[];
111111

112112
struct pt_regs;
113113

114+
#ifdef CONFIG_CALL_PADDING
115+
#define CFI_OFFSET (CONFIG_FUNCTION_PADDING_CFI+5)
116+
#else
117+
#define CFI_OFFSET 5
118+
#endif
119+
114120
#ifdef CONFIG_CFI
115121
enum bug_trap_type handle_cfi_failure(struct pt_regs *regs);
116122
#define __bpfcall
@@ -119,11 +125,9 @@ static inline int cfi_get_offset(void)
119125
{
120126
switch (cfi_mode) {
121127
case CFI_FINEIBT:
122-
return 16;
128+
return /* fineibt_prefix_size */ 16;
123129
case CFI_KCFI:
124-
if (IS_ENABLED(CONFIG_CALL_PADDING))
125-
return 16;
126-
return 5;
130+
return CFI_OFFSET;
127131
default:
128132
return 0;
129133
}

arch/x86/include/asm/irqflags.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static __always_inline void native_local_irq_restore(unsigned long flags)
7777
#endif
7878

7979
#ifndef CONFIG_PARAVIRT
80-
#ifndef __ASSEMBLY__
80+
#ifndef __ASSEMBLER__
8181
/*
8282
* Used in the idle loop; sti takes one instruction cycle
8383
* to complete:
@@ -95,7 +95,7 @@ static __always_inline void halt(void)
9595
{
9696
native_halt();
9797
}
98-
#endif /* __ASSEMBLY__ */
98+
#endif /* __ASSEMBLER__ */
9999
#endif /* CONFIG_PARAVIRT */
100100

101101
#ifdef CONFIG_PARAVIRT_XXL

arch/x86/include/asm/linkage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
* Depending on -fpatchable-function-entry=N,N usage (CONFIG_CALL_PADDING) the
6969
* CFI symbol layout changes.
7070
*
71-
* Without CALL_THUNKS:
71+
* Without CALL_PADDING:
7272
*
7373
* .align FUNCTION_ALIGNMENT
7474
* __cfi_##name:
@@ -77,7 +77,7 @@
7777
* .long __kcfi_typeid_##name
7878
* name:
7979
*
80-
* With CALL_THUNKS:
80+
* With CALL_PADDING:
8181
*
8282
* .align FUNCTION_ALIGNMENT
8383
* __cfi_##name:

arch/x86/include/asm/percpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#define PER_CPU_VAR(var) __percpu(var)__percpu_rel
2222

23-
#else /* !__ASSEMBLY__: */
23+
#else /* !__ASSEMBLER__: */
2424

2525
#include <linux/args.h>
2626
#include <linux/bits.h>

arch/x86/include/asm/runtime-const.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#error "Cannot use runtime-const infrastructure from modules"
77
#endif
88

9-
#ifdef __ASSEMBLY__
9+
#ifdef __ASSEMBLER__
1010

1111
.macro RUNTIME_CONST_PTR sym reg
1212
movq $0x0123456789abcdef, %\reg
@@ -16,7 +16,7 @@
1616
.popsection
1717
.endm
1818

19-
#else /* __ASSEMBLY__ */
19+
#else /* __ASSEMBLER__ */
2020

2121
#define runtime_const_ptr(sym) ({ \
2222
typeof(sym) __ret; \
@@ -74,5 +74,5 @@ static inline void runtime_const_fixup(void (*fn)(void *, unsigned long),
7474
}
7575
}
7676

77-
#endif /* __ASSEMBLY__ */
77+
#endif /* __ASSEMBLER__ */
7878
#endif

arch/x86/include/asm/traps.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ extern int ibt_selftest_noendbr(void);
2525
void handle_invalid_op(struct pt_regs *regs);
2626
#endif
2727

28+
noinstr bool handle_bug(struct pt_regs *regs);
29+
2830
static inline int get_si_code(unsigned long condition)
2931
{
3032
if (condition & DR_STEP)

arch/x86/kernel/alternative.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ void __init_or_module noinline apply_seal_endbr(s32 *start, s32 *end)
11821182

11831183
poison_endbr(addr);
11841184
if (IS_ENABLED(CONFIG_FINEIBT))
1185-
poison_cfi(addr - 16);
1185+
poison_cfi(addr - CFI_OFFSET);
11861186
}
11871187
}
11881188

@@ -1389,6 +1389,8 @@ extern u8 fineibt_preamble_end[];
13891389
#define fineibt_preamble_ud 0x13
13901390
#define fineibt_preamble_hash 5
13911391

1392+
#define fineibt_prefix_size (fineibt_preamble_size - ENDBR_INSN_SIZE)
1393+
13921394
/*
13931395
* <fineibt_caller_start>:
13941396
* 0: b8 78 56 34 12 mov $0x12345678, %eax
@@ -1634,14 +1636,23 @@ static int cfi_rewrite_preamble(s32 *start, s32 *end)
16341636
* have determined there are no indirect calls to it and we
16351637
* don't need no CFI either.
16361638
*/
1637-
if (!is_endbr(addr + 16))
1639+
if (!is_endbr(addr + CFI_OFFSET))
16381640
continue;
16391641

16401642
hash = decode_preamble_hash(addr, &arity);
16411643
if (WARN(!hash, "no CFI hash found at: %pS %px %*ph\n",
16421644
addr, addr, 5, addr))
16431645
return -EINVAL;
16441646

1647+
/*
1648+
* FineIBT relies on being at func-16, so if the preamble is
1649+
* actually larger than that, place it the tail end.
1650+
*
1651+
* NOTE: this is possible with things like DEBUG_CALL_THUNKS
1652+
* and DEBUG_FORCE_FUNCTION_ALIGN_64B.
1653+
*/
1654+
addr += CFI_OFFSET - fineibt_prefix_size;
1655+
16451656
text_poke_early(addr, fineibt_preamble_start, fineibt_preamble_size);
16461657
WARN_ON(*(u32 *)(addr + fineibt_preamble_hash) != 0x12345678);
16471658
text_poke_early(addr + fineibt_preamble_hash, &hash, 4);
@@ -1664,10 +1675,10 @@ static void cfi_rewrite_endbr(s32 *start, s32 *end)
16641675
for (s = start; s < end; s++) {
16651676
void *addr = (void *)s + *s;
16661677

1667-
if (!exact_endbr(addr + 16))
1678+
if (!exact_endbr(addr + CFI_OFFSET))
16681679
continue;
16691680

1670-
poison_endbr(addr + 16);
1681+
poison_endbr(addr + CFI_OFFSET);
16711682
}
16721683
}
16731684

@@ -1772,7 +1783,8 @@ static void __apply_fineibt(s32 *start_retpoline, s32 *end_retpoline,
17721783
if (FINEIBT_WARN(fineibt_preamble_size, 20) ||
17731784
FINEIBT_WARN(fineibt_preamble_bhi + fineibt_bhi1_size, 20) ||
17741785
FINEIBT_WARN(fineibt_caller_size, 14) ||
1775-
FINEIBT_WARN(fineibt_paranoid_size, 20))
1786+
FINEIBT_WARN(fineibt_paranoid_size, 20) ||
1787+
WARN_ON_ONCE(CFI_OFFSET < fineibt_prefix_size))
17761788
return;
17771789

17781790
if (cfi_mode == CFI_AUTO) {
@@ -1885,6 +1897,11 @@ static void poison_cfi(void *addr)
18851897
*/
18861898
switch (cfi_mode) {
18871899
case CFI_FINEIBT:
1900+
/*
1901+
* FineIBT preamble is at func-16.
1902+
*/
1903+
addr += CFI_OFFSET - fineibt_prefix_size;
1904+
18881905
/*
18891906
* FineIBT prefix should start with an ENDBR.
18901907
*/
@@ -1923,8 +1940,6 @@ static void poison_cfi(void *addr)
19231940
}
19241941
}
19251942

1926-
#define fineibt_prefix_size (fineibt_preamble_size - ENDBR_INSN_SIZE)
1927-
19281943
/*
19291944
* When regs->ip points to a 0xD6 byte in the FineIBT preamble,
19301945
* return true and fill out target and type.

arch/x86/kernel/traps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static inline void handle_invalid_op(struct pt_regs *regs)
397397
ILL_ILLOPN, error_get_trap_addr(regs));
398398
}
399399

400-
static noinstr bool handle_bug(struct pt_regs *regs)
400+
noinstr bool handle_bug(struct pt_regs *regs)
401401
{
402402
unsigned long addr = regs->ip;
403403
bool handled = false;

0 commit comments

Comments
 (0)