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: <ba080e23-18b1-4ab5-baa8-62bc09a98e38@infradead.org>
Date: Tue, 26 Dec 2023 13:09:46 -0800
From: Randy Dunlap <rdunlap@...radead.org>
To: Tom Zanussi <tom.zanussi@...ux.intel.com>, herbert@...dor.apana.org.au,
 davem@...emloft.net, fenghua.yu@...el.com
Cc: rex.zhang@...el.com, dave.jiang@...el.com, tony.luck@...el.com,
 linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
 dmaengine@...r.kernel.org
Subject: Re: [PATCH] crypto: iaa - Account for cpu-less numa nodes

Hi--

On 12/26/23 12:53, Tom Zanussi wrote:
> In some configurations e.g. systems with CXL, a numa node can have 0
> cpus and cpumask_nth() will return a cpu value that doesn't exist,
> which will result in an attempt to add an entry to the wq table at a
> bad index.
> 
> To fix this, when iterating the cpus for a node, skip any node that
> doesn't have cpus.
> 
> Also, as a precaution, add a warning and bail if cpumask_nth() returns
> a nonexistent cpu.
> 
> Reported-by: Zhang, Rex <rex.zhang@...el.com>
> Signed-off-by: Tom Zanussi <tom.zanussi@...ux.intel.com>
> ---
>  drivers/crypto/intel/iaa/iaa_crypto_main.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c
> index 5093361b0107..782157a74043 100644
> --- a/drivers/crypto/intel/iaa/iaa_crypto_main.c
> +++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c
> @@ -1017,12 +1017,17 @@ static void rebalance_wq_table(void)
>  		return;
>  	}
>  
> -	for_each_online_node(node) {
> +	for_each_node_with_cpus(node) {
>  		node_cpus = cpumask_of_node(node);
>  
>  		for (cpu = 0; cpu < nr_cpus_per_node; cpu++) {
>  			int node_cpu = cpumask_nth(cpu, node_cpus);
>  
> +			if (WARN_ON(node_cpu >= nr_cpu_ids)) {
> +				pr_debug("node_cpu %d doesn't exist!\n", node_cpu);
> +				return;
> +			}
> +
>  			if ((cpu % cpus_per_iaa) == 0)
>  				iaa++;
>  
> @@ -2095,10 +2100,13 @@ static struct idxd_device_driver iaa_crypto_driver = {
>  static int __init iaa_crypto_init_module(void)
>  {
>  	int ret = 0;
> +	int node;
>  
>  	nr_cpus = num_online_cpus();
> -	nr_nodes = num_online_nodes();
> -	nr_cpus_per_node = nr_cpus / nr_nodes;
> +	for_each_node_with_cpus(node)
> +		nr_nodes++;
> +	if (nr_nodes)
> +		nr_cpus_per_node = nr_cpus / nr_nodes;

If nr_nodes == 0, nr_cpus_per_node is not initialized here.
Is it initialized somewhere else, or just not used if nr_nodes is 0?

>  
>  	if (crypto_has_comp("deflate-generic", 0, 0))
>  		deflate_generic_tfm = crypto_alloc_comp("deflate-generic", 0, 0);

-- 
#Randy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ