lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251024140832.46JNLRvL@linutronix.de>
Date: Fri, 24 Oct 2025 16:08:32 +0200
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Nam Cao <namcao@...utronix.de>
Cc: Ingo Molnar <mingo@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
	Juri Lelli <juri.lelli@...hat.com>,
	Vincent Guittot <vincent.guittot@...aro.org>,
	Dietmar Eggemann <dietmar.eggemann@....com>,
	Mel Gorman <mgorman@...e.de>,
	Shrikanth Hegde <sshegde@...ux.ibm.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Valentin Schneider <vschneid@...hat.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] smp: Suppress false DEBUG_PREEMPT warning in
 smp_call_on_cpu()

On 2025-10-24 09:07:14 [+0200], Nam Cao wrote:
> While booting UP (uniprocessor) kernel with CONFIG_DEBUG_PREEMPT=y, the
> following warning is observed:
> 
> BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
> caller is debug_smp_processor_id+0x1c/0x28
> CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.0-rc2-00012-g002733e953a7 #111 PREEMPT_RT
> Hardware name: MangoPi MQ Pro (DT)
> Call Trace:
>     dump_backtrace
>     show_stack
>     dump_stack_lvl
>     dump_stack
>     check_preemption_disabled.isra.0
>     debug_smp_processor_id
>     check_unaligned_access
>     smp_call_on_cpu
>     check_unaligned_access_all_cpus
>     do_one_initcall
>     kernel_init_freeable
>     kernel_init
>     ret_from_fork_kernel
>     ret_from_fork_kernel_asm

Can be compressed to:

   Using smp_processor_id() in a smp_call_on_cpu() callback triggers a
   "using ... in preemptible" warning in UP builds.

> This is a false warning. The UP-variant of smp_call_on_cpu() simply calls
> the callback, and thus debug_smp_processor_id() thinks the context is
> unsafe for smp_processor_id(), which is obviously false because this is UP
> kernel.

"Only the UP implementation is affected by this"

> This appears after commit 06ddd17521bf ("sched/smp: Always define
> is_percpu_thread() and scheduler_ipi()"). Before this commit,
> is_percpu_thread() always returns true on UP kernel and thus
> debug_smp_processor_id() always sees a per-cpu thread and never warns. But
> now is_percpu_thread() returns false for this case.
> 
> Suppress this warning with a migrate_disable()+migrate_enable() pair.

Right. This is one of the possibilities. The other one would be to also
workqueue on UP and preserve the same semantic.
I don't mind this.

> Fixes: 06ddd17521bf ("sched/smp: Always define is_percpu_thread() and scheduler_ipi()")
> Signed-off-by: Nam Cao <namcao@...utronix.de>
> ---
> grep shows me that the followings also have the same false warning:
> 
>     arch/arm64/kernel/watchdog_hld.c
>     drivers/hwmon/dell-smm-hwmon.c
>     drivers/platform/x86/dell/dcdbas.c
>     kernel/watchdog.c
> ---
>  kernel/up.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/kernel/up.c b/kernel/up.c
> index df50828cc2f0..37c9f0d39b36 100644
> --- a/kernel/up.c
> +++ b/kernel/up.c
> @@ -64,7 +64,14 @@ int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys)
>  
>  	if (phys)
>  		hypervisor_pin_vcpu(0);
> +
> +	/* suppress warnings from debug_smp_processor_id() */

If you want to add a comment, what about something like

  /* Preserve not being migratable such as SMP variant does */ 

> +	migrate_disable();
> +
>  	ret = func(par);
> +
> +	migrate_enable();
> +
>  	if (phys)
>  		hypervisor_pin_vcpu(-1);
>  

Sebastian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ