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]
Date:   Tue, 30 Jul 2019 16:05:02 -0700
From:   Jakub Kicinski <jakub.kicinski@...ronome.com>
To:     Takshak Chahande <ctakshak@...com>
Cc:     <netdev@...r.kernel.org>, <ast@...nel.org>, <daniel@...earbox.net>,
        <rdna@...com>, <kernel-team@...com>, <hechaol@...com>
Subject: Re: [PATCH bpf-next] libbpf : make libbpf_num_possible_cpus
 function thread safe

On Tue, 30 Jul 2019 15:24:47 -0700, Takshak Chahande wrote:
> Having static variable `cpus` in libbpf_num_possible_cpus function without
> guarding it with mutex makes this function thread-unsafe.
> 
> If multiple threads accessing this function, in the current form; it
> leads to incrementing the static variable value `cpus` in the multiple
> of total available CPUs.
> 
> Let caching the number of possile CPUs handled by libbpf's users than
> this library itself; 

Can we just use stack variable for the calculations and
READ_ONCE()/WRITE_ONCE() for assignment to the static?  
libbpf itself uses this helper so caller caching wouldn't
work there.

> and let this function be rock bottom one which reads
> and parse the file (/sys/devices/system/cpu/possible) everytime it gets
> called to simplify the things.

I don't understand can you rephrase?

> Fixes: 6446b3155521 (bpf: add a new API libbpf_num_possible_cpus())
> 

No new line after the fixes tag, also I think you're missing quotation
marks around the commit title?

> Signed-off-by: Takshak Chahande <ctakshak@...com>
> Acked-by: Andrey Ignatov <rdna@...com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ