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: <54bd3d6c-d763-ae09-6ee2-7ef192a97ca9@google.com>
Date: Wed, 21 May 2025 08:58:32 -0700 (PDT)
From: Hugh Dickins <hughd@...gle.com>
To: Oscar Salvador <osalvador@...e.de>
cc: Hugh Dickins <hughd@...gle.com>, Gavin Guo <gavinguo@...lia.com>, 
    linux-mm@...ck.org, linux-kernel@...r.kernel.org, muchun.song@...ux.dev, 
    akpm@...ux-foundation.org, kernel-dev@...lia.com, stable@...r.kernel.org, 
    Florent Revest <revest@...gle.com>, Gavin Shan <gshan@...hat.com>
Subject: Re: [PATCH v2] mm/hugetlb: fix a deadlock with pagecache_folio and
 hugetlb_fault_mutex_table

On Wed, 21 May 2025, Oscar Salvador wrote:
> On Wed, May 21, 2025 at 08:10:46AM -0700, Hugh Dickins wrote:
> > Unless you have a very strong argument why this folio is invisible to
> > the rest of the world, including speculative accessors like compaction
> > (and the name "pagecache_folio" suggests very much the reverse): the
> > pattern of unlocking a lock when you see it locked is like (or worse
> > than) having no locking at all - it is potentially unlocking someone
> > else's lock.
> 
> hugetlb_fault() locks 'pagecache_folio' and unlocks it after returning
> from hugetlb_wp().
> This patch introduces the possibility that hugetlb_wp() can also unlock it for
> the reasons explained.
> So, when hugetlb_wp() returns back to hugetlb_fault(), we
> 
> 1) either still hold the lock (because hugetlb_fault() took it)
> 2) or we do not anymore because hugetlb_wp() unlocked it for us.
> 
> So it is not that we are unlocking anything blindly, because if the lock
> is still 'taken' (folio_test_locked() returned true) it is because we,
> hugetlb_fault() took it and we are still holding it.

If we unlocked it, anyone else could have taken it immediately after.

Hugh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ