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: <b7ae0457-2663-4f8d-a6f7-b79dd60623d1@gaisler.com>
Date: Wed, 8 May 2024 19:32:42 +0200
From: Andreas Larsson <andreas@...sler.com>
To: Dawei Li <dawei.li@...ngroup.cn>, davem@...emloft.net
Cc: sparclinux@...r.kernel.org, linux-kernel@...r.kernel.org, sam@...nborg.org
Subject: Re: [PATCH v4 5/5] sparc/leon: Remove on-stack cpumask var

On 2024-04-24 04:55, Dawei Li wrote:
> In general it's preferable to avoid placing cpumasks on the stack, as
> for large values of NR_CPUS these can consume significant amounts of
> stack space and make stack overflows more likely.
> 
> Use cpumask_subset() and cpumask_first_and() to avoid the need for a
> temporary cpumask on the stack.
> 
> Reviewed-by: Sam Ravnborg <sam@...nborg.org>
> Signed-off-by: Dawei Li <dawei.li@...ngroup.cn>
> ---
>  arch/sparc/kernel/leon_kernel.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
> index 4c61da491fee..a43cf794bb1e 100644
> --- a/arch/sparc/kernel/leon_kernel.c
> +++ b/arch/sparc/kernel/leon_kernel.c
> @@ -106,13 +106,12 @@ unsigned long leon_get_irqmask(unsigned int irq)
>  #ifdef CONFIG_SMP
>  static int irq_choose_cpu(const struct cpumask *affinity)
>  {
> -	cpumask_t mask;
> +	unsigned int cpu = cpumask_first_and(affinity, cpu_online_mask);
>  
> -	cpumask_and(&mask, cpu_online_mask, affinity);
> -	if (cpumask_equal(&mask, cpu_online_mask) || cpumask_empty(&mask))
> +	if (cpumask_subset(cpu_online_mask, affinity) || cpu >= nr_cpu_ids)
>  		return boot_cpu_id;
>  	else
> -		return cpumask_first(&mask);
> +		return cpu;
>  }
>  #else
>  #define irq_choose_cpu(affinity) boot_cpu_id

Reviewed-by: Andreas Larsson <andreas@...sler.com>
Tested-by: Andreas Larsson <andreas@...sler.com>

Picking this up to my for-next.

Thanks,
Andreas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ