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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 6 Sep 2022 15:57:30 +0200
From:   David Hildenbrand <david@...hat.com>
To:     Jason Gunthorpe <jgg@...dia.com>
Cc:     John Hubbard <jhubbard@...dia.com>, Yang Shi <shy828301@...il.com>,
        peterx@...hat.com, kirill.shutemov@...ux.intel.com,
        hughd@...gle.com, akpm@...ux-foundation.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: gup: fix the fast GUP race against THP collapse

On 06.09.22 15:47, Jason Gunthorpe wrote:
> On Mon, Sep 05, 2022 at 09:59:47AM +0200, David Hildenbrand wrote:
> 
>>> That should be READ_ONCE() for the *pmdp and *ptep reads. Because this
>>> whole lockless house of cards may fall apart if we try reading the
>>> page table values without READ_ONCE().
>>
>> I came to the conclusion that the implicit memory barrier when grabbing a
>> reference on the page is sufficient such that we don't need READ_ONCE here.
> 
> READ_ONCE is not about barriers or ordering, you still need the
> acquire inside the atomic to make the algorithm work.


While I don't disagree with what say is, I'll refer to 
Documentation/memory-barriers.txt "COMPILER BARRIER".

As discussed somewhere in this thread, if we already have an atomic RWM 
that implies a full ordering, it implies a compile barrier.


> 
> READ_ONCE primarily is a marker that the data being read is unstable
> and that the compiler must avoid all instability when reading it. eg
> in this case the compiler could insanely double read the value, even
> though the 'if' requires only a single read. This would result in
> corrupt calculation.

As we have a full memory barrier + compile barrier, the compiler might 
indeed do double reads and all that stuff. BUT, it has to re-read after 
we incremented the refcount, and IMHO that's the important part to 
detect the change.



-- 
Thanks,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ