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, 16 Jan 2024 09:23:07 +0800
From: "Huang, Ying" <ying.huang@...el.com>
To: Pierre Gondois <pierre.gondois@....com>
Cc: <linux-kernel@...r.kernel.org>,  Shrikanth Hegde
 <sshegde@...ux.vnet.ibm.com>,  Ingo Molnar <mingo@...hat.com>,  Peter
 Zijlstra <peterz@...radead.org>,  Juri Lelli <juri.lelli@...hat.com>,
  Vincent Guittot <vincent.guittot@...aro.org>,  Dietmar Eggemann
 <dietmar.eggemann@....com>,  Steven Rostedt <rostedt@...dmis.org>,  Ben
 Segall <bsegall@...gle.com>,  "Mel Gorman" <mgorman@...e.de>,  Daniel
 Bristot de Oliveira <bristot@...hat.com>,  Valentin Schneider
 <vschneid@...hat.com>
Subject: Re: [PATCH v2 1/3] sched/topology: Annotate RCU pointers properly

Pierre Gondois <pierre.gondois@....com> writes:

> Cleanup RCU-related spare errors by annotating RCU pointers.
>
> sched_domains_numa_distance:
>   error: incompatible types in comparison expression
>   (different address spaces):
>       int [noderef] __rcu *
>       int *
>
> sched_domains_numa_masks:
>   error: incompatible types in comparison expression
>   (different address spaces):
>       struct cpumask **[noderef] __rcu *
>       struct cpumask ***
>
> The cast to (void *) adds the following sparse warning:
>   warning: cast removes address space '__rcu' of expression
> but this should be normal.
>
> Fixes: 0fb3978b0aac ("sched/numa: Fix NUMA topology for systems with CPU-less nodes")
> Signed-off-by: Pierre Gondois <pierre.gondois@....com>
> ---
>  kernel/sched/topology.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 10d1391e7416..2a2da9b33e31 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -1542,8 +1542,8 @@ static int			sched_domains_numa_levels;
>  static int			sched_domains_curr_level;
>  
>  int				sched_max_numa_distance;
> -static int			*sched_domains_numa_distance;
> -static struct cpumask		***sched_domains_numa_masks;
> +static int			__rcu *sched_domains_numa_distance;
> +static struct cpumask		** __rcu *sched_domains_numa_masks;
>  #endif
>  
>  /*
> @@ -1988,8 +1988,8 @@ void sched_init_numa(int offline_node)
>  
>  static void sched_reset_numa(void)
>  {
> -	int nr_levels, *distances;
> -	struct cpumask ***masks;
> +	int nr_levels, __rcu *distances;
> +	struct cpumask ** __rcu *masks;

No.  distances and masks are not accessed via RCU in the function.
Instead, they should be assigned like below,

         distances = rcu_dereference_raw(sched_domains_numa_distance);

Because sched_domains_numa_distance is protected by cpu_hotplug_lock,
but the lock is static.  Some comments are deserved.

Anyway, please read RCU document before making the change.

https://docs.kernel.org/RCU/index.html

>  	nr_levels = sched_domains_numa_levels;
>  	sched_domains_numa_levels = 0;
> @@ -2003,7 +2003,7 @@ static void sched_reset_numa(void)
>  		int i, j;
>  
>  		synchronize_rcu();
> -		kfree(distances);
> +		kfree((void *)distances);
>  		for (i = 0; i < nr_levels && masks; i++) {
>  			if (!masks[i])
>  				continue;
> @@ -2011,7 +2011,7 @@ static void sched_reset_numa(void)
>  				kfree(masks[i][j]);
>  			kfree(masks[i]);
>  		}
> -		kfree(masks);
> +		kfree((void *)masks);
>  	}
>  	if (sched_domain_topology_saved) {
>  		kfree(sched_domain_topology);

--
Best Regards,
Huang, Ying

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ