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]
Message-ID: <20201113160234.GB44988@C02TD0UTHF1T.local>
Date:   Fri, 13 Nov 2020 16:02:34 +0000
From:   Mark Rutland <mark.rutland@....com>
To:     Ionela Voinescu <ionela.voinescu@....com>
Cc:     catalin.marinas@....com, sudeep.holla@....com, will@...nel.org,
        morten.rasmussen@....com, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] arm64: abort counter_read_on_cpu() when irqs_disabled()

On Fri, Nov 13, 2020 at 03:53:28PM +0000, Ionela Voinescu wrote:
> Given that smp_call_function_single() can deadlock when interrupts are
> disabled, abort the SMP call if irqs_disabled(). This scenario is
> currently not possible given the function's uses, but safeguard this for
> potential future uses.

Sorry to contradict earlier feedback, but I think this is preferable
as-is, since smp_call_function_single() will
WARN_ON_ONCE(irqs_disabled())), but this will silently mask any dodgy
usage.

If we want a separate check here, I reckon we should wrap it with a
WARN_ON_ONCE(), and only relax that if/when we have a legitimate case
for calling this with IRQs disabled.

Thanks,
Mark.

> 
> Signed-off-by: Ionela Voinescu <ionela.voinescu@....com>
> Cc: Catalin Marinas <catalin.marinas@....com>
> Cc: Will Deacon <will@...nel.org>
> ---
>  arch/arm64/kernel/topology.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
> index 3a083a9a8ef2..e387188741f2 100644
> --- a/arch/arm64/kernel/topology.c
> +++ b/arch/arm64/kernel/topology.c
> @@ -343,7 +343,11 @@ static void cpu_read_constcnt(void *val)
>  static inline
>  int counters_read_on_cpu(int cpu, smp_call_func_t func, u64 *val)
>  {
> -	if (!cpu_has_amu_feat(cpu))
> +	/*
> +	 * Abort call on counterless CPU or when interrupts are
> +	 * disabled - can lead to deadlock in smp sync call.
> +	 */
> +	if (!cpu_has_amu_feat(cpu) || unlikely(irqs_disabled()))
>  		return -EOPNOTSUPP;
>  
>  	smp_call_function_single(cpu, func, val, 1);
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ