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] [day] [month] [year] [list]
Message-ID: <e717c028-eb87-4414-a967-f1144ae0fb0b@suse.cz>
Date: Mon, 14 Jul 2025 09:10:43 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Jeongjun Park <aha310510@...il.com>, dennis@...nel.org, tj@...nel.org,
 cl@...two.org, roman.gushchin@...ux.dev, rientjes@...gle.com,
 shakeel.butt@...ux.dev, linux-mm@...ck.org, linux-kernel@...r.kernel.org,
 syzbot+e5bd32b79413e86f389e@...kaller.appspotmail.com
Subject: Re: [PATCH v2] mm/percpu: prevent concurrency problem for
 pcpu_nr_populated read with spin lock

On 7/13/25 00:28, Andrew Morton wrote:
> On Fri, 11 Jul 2025 17:56:34 +0200 Vlastimil Babka <vbabka@...e.cz> wrote:
> 
>> On 7/3/25 08:56, Jeongjun Park wrote:
>> > pcpu_nr_pages() reads pcpu_nr_populated without any protection, which
>> > causes a data race between read/write.
>> > 
>> > However, since this is an intended race, we should add a data_race
>> > annotation instead of add a spin lock.
>> > 
>> > Reported-by: syzbot+e5bd32b79413e86f389e@...kaller.appspotmail.com
>> > Fixes: 7e8a6304d541 ("/proc/meminfo: add percpu populated pages count")
>> > Suggested-by: Shakeel Butt <shakeel.butt@...ux.dev>
>> > Signed-off-by: Jeongjun Park <aha310510@...il.com>
>> > ---
>> > v2: Change it as suggested by Shakeel Butt
>> > - Link to v1: https://lore.kernel.org/all/20250702082749.141616-1-aha310510@gmail.com/
>> > ---
>> >  mm/percpu.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> > 
>> > diff --git a/mm/percpu.c b/mm/percpu.c
>> > index b35494c8ede2..782cc148b39c 100644
>> > --- a/mm/percpu.c
>> > +++ b/mm/percpu.c
>> > @@ -3355,7 +3355,7 @@ void __init setup_per_cpu_areas(void)
>> >   */
>> >  unsigned long pcpu_nr_pages(void)
>> >  {
>> > -	return pcpu_nr_populated * pcpu_nr_units;
>> > +	return data_race(READ_ONCE(pcpu_nr_populated) * pcpu_nr_units);
>> 
>> Nit: pcpu_nr_units should be excluded from the scope of data_race() as no
>> race can happen there.
> 
> This?
> 
> --- a/mm/percpu.c~mm-percpu-prevent-concurrency-problem-for-pcpu_nr_populated-read-with-spin-lock-fix
> +++ a/mm/percpu.c
> @@ -3355,7 +3355,7 @@ void __init setup_per_cpu_areas(void)
>   */
>  unsigned long pcpu_nr_pages(void)
>  {
> -	return data_race(READ_ONCE(pcpu_nr_populated) * pcpu_nr_units);
> +	return data_race(READ_ONCE(pcpu_nr_populated)) * pcpu_nr_units;

Yes, thanks!

>  }
>  
>  /*
> _
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ