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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 22 Mar 2022 11:38:09 +0000
From:   Vincent Donnefort <vincent.donnefort@....com>
To:     Steven Price <steven.price@....com>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>
Cc:     linux-kernel@...r.kernel.org, Baokun Li <libaokun1@...wei.com>,
        Dongli Zhang <dongli.zhang@...cle.com>,
        Randy Dunlap <rdunlap@...radead.org>,
        Yuan ZhaoXiong <yuanzhaoxiong@...du.com>,
        YueHaibing <yuehaibing@...wei.com>,
        Dietmar Eggemann <dietmar.eggemann@....com>
Subject: Re: [PATCH v2] cpu/hotplug: Set st->cpu earlier


On 16/03/2022 15:36, Steven Price wrote:
> Setting the 'cpu' member of struct cpuhp_cpu_state in cpuhp_create() is
> too late as other callbacks can be made before that point. In particular
> if one of the earlier callbacks fails and triggers a rollback that
> rollback will be done with st->cpu==0 causing CPU0 to be erroneously set
> to be dying, causing the scheduler to get mightily confused and throw
> its toys out of the pram.
> 
> Move the assignment earlier before any callbacks have a chance to run.
> 
> Fixes: 2ea46c6fc945 ("cpumask/hotplug: Fix cpu_dying() state tracking")
> Signed-off-by: Steven Price <steven.price@....com>
> CC: Dietmar Eggemann <dietmar.eggemann@....com>
> ---
> Changes since v1[1]:
> 
>   * Added a Fixes: tag.
>   * Moved the assignment to just before cpuhp_set_state() which is the
>     first place it is needed.
> 
> [1]: https://lore.kernel.org/r/20220225134918.105796-1-steven.price%40arm.com
> 
>   kernel/cpu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index 407a2568f35e..c1324c8677cf 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -720,7 +720,6 @@ static void cpuhp_create(unsigned int cpu)
>   
>   	init_completion(&st->done_up);
>   	init_completion(&st->done_down);
> -	st->cpu = cpu;
>   }
>   
>   static int cpuhp_should_run(unsigned int cpu)
> @@ -1351,6 +1350,7 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
>   
>   	cpuhp_tasks_frozen = tasks_frozen;
>   
> +	st->cpu = cpu;
>   	cpuhp_set_state(st, target);
>   	/*
>   	 * If the current CPU state is in the range of the AP hotplug thread,

Reviewed-by: Vincent Donnefort <vincent.donnefort@....com>

I also gave a try with LISA's HotplugRollback test.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ