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: <20231019084459.GP33217@noisy.programming.kicks-ass.net>
Date:   Thu, 19 Oct 2023 10:44:59 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     Uros Bizjak <ubizjak@...il.com>, Nadav Amit <namit@...are.com>,
        the arch/x86 maintainers <x86@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Andy Lutomirski <luto@...nel.org>,
        Brian Gerst <brgerst@...il.com>,
        Denys Vlasenko <dvlasenk@...hat.com>,
        "H . Peter Anvin" <hpa@...or.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>
Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr()

On Wed, Oct 18, 2023 at 03:40:05PM -0700, Linus Torvalds wrote:

> Side note: the code that caused that problem is this:
> 
>   __always_inline void __cyc2ns_read(struct cyc2ns_data *data)
>   {
>         int seq, idx;
> 
>         do {
>                 seq = this_cpu_read(cyc2ns.seq.seqcount.sequence);
>                 ...
>         } while (unlikely(seq != this_cpu_read(cyc2ns.seq.seqcount.sequence)));
>   }
> 
> where the issue is that the this_cpu_read() of that sequence number
> needs to be ordered.

I have very vague memories of other code also relying on this_cpu_read()
implying READ_ONCE().

And that code really only is buggy if you do not have that. Since it is
cpu local, the smp_rmb() would be confusing, as would smp_load_acquire()
be -- there is no cross-cpu data ordering.

The other option is of couse adding explicit barrier(), but that's
entirely superfluous when all the loads are READ_ONCE().


If you want to make this_cpu_read() not imply READ_ONCE(), then we
should go audit all users :/ Can be done ofc.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ