From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796007165; b=eFJO/xJVSPVQWgAUNShb85DIyPkNHVJDf3sbIros1UIgfw/JwWxNLIZwgzS2tGmfzawu BdcmhX4siw6KJN1GDChYRLLySRSqQFs/p8HSedKVG8V7SzidBDMyXPG/EY9VBNekGM4JI aAfdK/+GPoQzwMQ59TnGMY8Ijk/qEOhJFnBcNc+DBkmmMKwWYp1vqHFKdZETcNy5zrFjH /VbwbIVhNvNcsy3YWrjhfVHVpcH2tz+LLS/IY/grF2Lw79yojdm1bVbDCFmSRZABnXhek KnIxazY0nsgTEYQ0lEFvNWYwG7gLKTTf2Cr/cmxuj2PqhbXQ/SZ8dnv0cESiClctthQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796007165; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=Z8hPIiK/pFot8ogEKenI3OUHXEBUbDv5kSfaaKNyggw=; b=xe8dxCKnrvYc3yJvr/VmAI2GwonNXVIcE5RFP+0m9S2Q0JoK+TuJz/rhFkXD7TJiwqHq AubeaJWOqmecCqbZrVGNE9Z+5ZWbviaLPoBoza6K4sL/zRNXJhFvmaUvtq1XagJuTWCf6 xHyf62tsXSwuEZYgj1SSMLEui6ozte2qePzSQlRu+fOTjCn0mEMdP2zqoYEl1xOoWUPnQ uytHWnn63QkGDyMw/ofpHEAUgPvFqLOicnFA9xCXw6obX1anNIBjRG/tGUGhwthfQcOzk ZZF2N+gHxGhMFUGi8x0jW99SwZPNEqbZPkElK5XL7I8Ffhhi76ja8AwGt2gihCizySQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=KxcjZYOl; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54C24606A31C for ; Mon, 30 Nov 2026 02:52:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=KxcjZYOl Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2C911F000C1; Mon, 30 Nov 2026 02:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796007164; bh=Z8hPIiK/pFot8ogEKenI3OUHXEBUbDv5kSfaaKNyggw=; h=Date:To:From:In-Reply-To:References:Subject; b=KxcjZYOl4Fn8sqY8gYDPhtxkhSYhB7VOy1pUhYhS8sD3Be+STEI2cFsmTXz5Ljmc+ O7hyXAVPQSeluH1cSGcGUxXAEDpNt3xB3ZI7SLnE8oEOQwo4V75jXuRR84l62ohrV8 HrHWkwvitV+DVf41Qi17smZddfli55CcFuYvR6Qg= Date: Sun, 29 Nov 2026 18:52:44 -0800 To: mm-commits@vger.kernel.org,mason@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261125-hugetlb_fixes_2-v1-20-db27fd2f71a8@kernel.org> References: <20261125-hugetlb_fixes_2-v1-20-db27fd2f71a8@kernel.org> Subject: + mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch added to mm-new branch Message-Id: <20261130025244.B2C911F000C1@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm/hugetlb: resolve protnone faults without a uffd bit has been added to the -mm mm-new branch. Its filename is mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Chris Mason Subject: mm/hugetlb: resolve protnone faults without a uffd bit Date: Wed, 25 Nov 2026 23:33:18 +0100 hugetlb_fault() only restores the protection of protnone entries that have the uffd bit set, assuming that accessible VMAs cannot have other protnone entries. If such an entry existed nevertheless, any access to it would result in an endless fault loop. We are not aware of a way to trigger this: paths that drop the uffd bit (fork(), mremap(), unregistering) restore the protection, and remove_migration_pte() only drops the uffd bit for writable migration entries, which cannot be created from protnone entries. Let's be defensive and make any protnone entry in an accessible VMA accessible again, unless it is an RWP fault that has to be reported to user space, like do_numa_page() does for small folios. [david@kernel.org: adjust comments and description] Link: https://patch.msgid.link/20261125-hugetlb_fixes_2-v1-20-db27fd2f71a8@kernel.org Signed-off-by: Chris Mason Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Andrew Morton Cc: Muchun Song Cc: Oscar Salvador Cc: Jinmeng Zhou Cc: Hongfu Li Cc: Andrea Arcangeli Cc: Mike Kravetz Cc: Naoya Horiguchi Cc: Hugh Dickins Cc: Baolin Wang Cc: Dave Airlie Cc: Vivek Kasireddy Cc: Gerd Hoffmann Cc: Mike Rapoport Cc: Mel Gorman Cc: Dave McCracken Cc: Andy Whitcroft Cc: Adam Litke Cc: Lorenzo Stoakes Cc: Rik van Riel Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Harry Yoo Cc: Jann Horn Cc: Lance Yang Cc: James Houghton Cc: Yang Shi Cc: Suren Baghdasaryan Cc: Shakeel Butt Cc: Pedro Falcato Cc: Gregory Price Cc: Zi Yan Cc: Joshua Hahn Cc: Rakie Kim Cc: Ying Huang Cc: Matthew Brost Cc: Byungchul Park Cc: Alistair Popple Cc: Wanpeng Li Cc: Andi Kleen Cc: Kenneth W Chen Cc: Michal Hocko Cc: David Rientjes Cc: Joern Engel Cc: Jonathan Corbet Cc: Shuah Khan Cc: Randy Dunlap Cc: Aneesh Kumar K.V Cc: KAMEZAWA Hiroyuki Cc: Kiryl Shutsemau Cc: Sasha Levin Cc: Guillaume Morin Cc: Wanpeng Li Cc: Jason Gunthorpe Cc: luojiajun Cc: Josef Bacik Cc: Daehyeon Ko <4ncienth@gmail.com> Cc: Ackerley Tng Cc: "Oscar Salvador (SUSE)" Cc: Jiaqi Yan mm/hugetlb.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) --- a/mm/hugetlb.c~mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit +++ a/mm/hugetlb.c @@ -6332,32 +6332,33 @@ vm_fault_t hugetlb_fault(struct mm_struc } /* - * Protnone hugetlb PTEs with the uffd bit are used by - * userfaultfd RWP for access tracking. Plain PROT_NONE (without the - * marker) is not an RWP fault and is not expected on hugetlb (no - * NUMA hinting), so let normal hugetlb fault handling proceed. + * Protnone hugetlb PTEs with the uffd bit are used by userfaultfd RWP + * for access tracking. Without the bit there is nothing to report, so + * just make the PTE accessible. */ - if (pte_protnone(vmf.orig_pte) && vma_is_accessible(vma) && - huge_pte_uffd(vmf.orig_pte)) { + if (pte_protnone(vmf.orig_pte) && vma_is_accessible(vma)) { spinlock_t *ptl; pte_t pte; /* Sync: drop hugetlb locks before blocking in handle_userfault() */ - if (userfaultfd_rwp(vma) && !userfaultfd_rwp_async(vma)) + if (huge_pte_uffd(vmf.orig_pte) && userfaultfd_rwp(vma) && + !userfaultfd_rwp_async(vma)) return hugetlb_handle_userfault(&vmf, mapping, VM_UFFD_RWP); ptl = huge_pte_lock(h, mm, vmf.pte); pte = huge_ptep_get(mm, vmf.address, vmf.pte); - /* - * TODO: fix all cases where uffd PTE bits remain in VMAs that - * are no longer registered with uffd. - */ - if (pte_protnone(pte) && huge_pte_uffd(pte)) { + if (pte_same(pte, vmf.orig_pte)) { unsigned int shift = huge_page_shift(h); pte = huge_pte_modify(pte, vma->vm_page_prot); pte = arch_make_huge_pte(pte, shift, vma->vm_flags); - /* huge_pte_modify() preserves _PAGE_UFFD; drop it on resolution */ + /* + * huge_pte_modify() preserves _PAGE_UFFD; drop it on + * resolution. + * + * TODO: fix all cases where uffd PTE bits remain in VMAs + * that are no longer registered with uffd. + */ pte = huge_pte_clear_uffd(pte); pte = pte_mkyoung(pte); /* _ Patches currently in -mm which might be from mason@kernel.org are mm-swap-fix-large-swap-in-across-swap-file-extents.patch hugetlbfs-do-not-grow-a-sealed-file-in-mmap.patch mm-hugetlb-keep-surplus-folios-that-are-reserved.patch mm-hugetlb-fix-reservation-leak-on-min_size=-mounts.patch mm-cachestat-count-each-page-only-once.patch mm-cachestat-restart-the-walk-after-each-entry.patch percpu-queue-the-balance-work-on-an-unbound-workqueue.patch mm-vma-fix-uncharge-after-failed-stack-relocation.patch mm-mremap-apply-the-mmap-offset-limits-on-expansion.patch mm-mremap-respect-guard-gaps-on-in-place-expansion.patch mm-vma-make-brk-mappings-non-executable-under-mdwe.patch mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch mm-mglru-count-all-generations-as-evictable.patch mm-mglru-test-pg_lru-before-taking-a-folio-reference.patch mm-mglru-report-root-reclaim-to-memorypressure_level.patch kfence-use-a-nofault-store-to-zero-the-guard-page.patch mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy.patch hugetlbfs-fix-deadlock-between-hole-punching-and-memory-failure.patch hugetlbfs-recheck-the-vma-range-after-the-lock-wait.patch mm-hugetlb-dont-zap-non-present-entries-when-unmapping-a-folio.patch mm-hugetlb-unshare-pmds-of-a-split-vma-if-allocating-its-lock-fails.patch mm-hugetlb_cgroup-track-in-use-folios-per-cgroup.patch hugetlbfs-seal-shm_hugetlb-files-against-growth.patch mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch