Re: [PATCH -next] x86: Prevent KASAN false positive warnings in __show_regs()

From: Tengda Wu
Date: Fri Aug 29 2025 - 05:45:26 EST




On 2025/8/29 3:16, Josh Poimboeuf wrote:
> On Thu, Aug 28, 2025 at 08:06:17PM +0800, Tengda Wu wrote:
>> +++ b/arch/x86/kernel/dumpstack.c
>> @@ -189,9 +189,15 @@ static void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
>> unsigned long visit_mask = 0;
>> int graph_idx = 0;
>> bool partial = false;
>> + bool kasan_disabled = false;
>>
>> printk("%sCall Trace:\n", log_lvl);
>>
>> + if (task != current) {
>> + kasan_disable_current();
>> + kasan_disabled = true;
>> + }
>
> Looks reasonable to me, though note that some callers pass a NULL @task
> to indicate 'current'.
>
> (No idea why, that subtlety should probably be removed...)
>
> So this might need to be
>
> if (task && task != current) {
> ...
>

Dave mentioned that there's an object_is_on_stack available, which is
essentially on_current_stack. I will try using it and send out v2.

Thanks,
Tengda