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] [day] [month] [year] [list]
Message-ID: <64ca8b7f-2b1f-40e8-b314-d59a3094d99f@igalia.com>
Date: Thu, 22 May 2025 14:06:29 +0800
From: Gavin Guo <gavinguo@...lia.com>
To: Hugh Dickins <hughd@...gle.com>, Oscar Salvador <osalvador@...e.de>
Cc: 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 5/21/25 23:58, Hugh Dickins wrote:
> 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
> _______________________________________________
> Kernel-dev mailing list -- kernel-dev@...lia.com
> To unsubscribe send an email to kernel-dev-leave@...lia.com

Sigh, I should have thought of that as well. Next time, I'll be more 
careful.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ