Skip to content

Commit dcd8637

Browse files
committed
Merge tag 'x86-core-2025-12-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull core x86 updates from Ingo Molnar: - x86/alternatives: Drop unnecessary test after call to alt_replace_call() (Juergen Gross) - x86/dumpstack: Prevent KASAN false positive warnings in __show_regs() (Tengda Wu) * tag 'x86-core-2025-12-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/dumpstack: Prevent KASAN false positive warnings in __show_regs() x86/alternative: Drop not needed test after call of alt_replace_call()
2 parents e7d81c1 + ced37e9 commit dcd8637

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

arch/x86/kernel/alternative.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ EXPORT_SYMBOL(BUG_func);
541541
* Rewrite the "call BUG_func" replacement to point to the target of the
542542
* indirect pv_ops call "call *disp(%ip)".
543543
*/
544-
static int alt_replace_call(u8 *instr, u8 *insn_buff, struct alt_instr *a)
544+
static unsigned int alt_replace_call(u8 *instr, u8 *insn_buff, struct alt_instr *a)
545545
{
546546
void *target, *bug = &BUG_func;
547547
s32 disp;
@@ -625,7 +625,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
625625
* order.
626626
*/
627627
for (a = start; a < end; a++) {
628-
int insn_buff_sz = 0;
628+
unsigned int insn_buff_sz = 0;
629629

630630
/*
631631
* In case of nested ALTERNATIVE()s the outer alternative might
@@ -665,11 +665,8 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
665665
memcpy(insn_buff, replacement, a->replacementlen);
666666
insn_buff_sz = a->replacementlen;
667667

668-
if (a->flags & ALT_FLAG_DIRECT_CALL) {
668+
if (a->flags & ALT_FLAG_DIRECT_CALL)
669669
insn_buff_sz = alt_replace_call(instr, insn_buff, a);
670-
if (insn_buff_sz < 0)
671-
continue;
672-
}
673670

674671
for (; insn_buff_sz < a->instrlen; insn_buff_sz++)
675672
insn_buff[insn_buff_sz] = 0x90;

arch/x86/kernel/dumpstack.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs,
181181
* in false positive reports. Disable instrumentation to avoid those.
182182
*/
183183
__no_kmsan_checks
184-
static void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
185-
unsigned long *stack, const char *log_lvl)
184+
static void __show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
185+
unsigned long *stack, const char *log_lvl)
186186
{
187187
struct unwind_state state;
188188
struct stack_info stack_info = {0};
@@ -303,6 +303,25 @@ static void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
303303
}
304304
}
305305

306+
static void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
307+
unsigned long *stack, const char *log_lvl)
308+
{
309+
/*
310+
* Disable KASAN to avoid false positives during walking another
311+
* task's stacks, as values on these stacks may change concurrently
312+
* with task execution.
313+
*/
314+
bool disable_kasan = task && task != current;
315+
316+
if (disable_kasan)
317+
kasan_disable_current();
318+
319+
__show_trace_log_lvl(task, regs, stack, log_lvl);
320+
321+
if (disable_kasan)
322+
kasan_enable_current();
323+
}
324+
306325
void show_stack(struct task_struct *task, unsigned long *sp,
307326
const char *loglvl)
308327
{

0 commit comments

Comments
 (0)