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: <CAGudoHEggB=F9j7r+ndQs1WxpRWB4O5VdBo+PLx+yd1xrj4-Ew@mail.gmail.com>
Date: Mon, 9 Dec 2024 11:25:37 +0100
From: Mateusz Guzik <mjguzik@...il.com>
To: David Hildenbrand <david@...hat.com>
Cc: yuzhao@...gle.com, akpm@...ux-foundation.org, willy@...radead.org, 
	linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH] mm: remove an avoidable load of page refcount in page_ref_add_unless

On Mon, Dec 9, 2024 at 10:28 AM David Hildenbrand <david@...hat.com> wrote:
>
> On 07.12.24 09:29, Mateusz Guzik wrote:
> > Explicitly pre-checking the count adds nothing as atomic_add_unless
> > starts with doing the same thing. iow no functional changes.
>
> I recall that we added that check because with the hugetlb vmemmap
> optimization, some of the tail pages we don't ever expect to be modified
>   (because they are fake-duplicated) might be mapped R/O.
>
> If the arch implementation of atomic_add_unless() would trigger an
> unconditional write fault, we'd be in trouble. That would likely only be
> the case if the arch provides a dedicate instruction.
>
> atomic_add_unless()->raw_atomic_add_unless()
>
> Nobody currently defines arch_atomic_add_unless().
>
> raw_atomic_fetch_add_unless()->arch_atomic_fetch_add_unless() is defined
> on some architectures.
>
> I scanned some of the inline-asm, and I think most of them perform a
> check first.
>

Huh.

Some arch triggering a write fault despite not changing the value is
not something I thought about. Sounds pretty broken to me if any arch
was to do it, but then stranger things did happen.

However, if this is seen as a real concern, then I think the best way
forward is to drop the patch (and maybe instead add a comment what's
up with the extra load).
-- 
Mateusz Guzik <mjguzik gmail.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ