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=1796325275; b=WthsFDhnWFE3/z0ttQ6qIoZeIdkgzB1ztjBAOQRI+Ee01Rp2O10KVjnDFC+Oh3a+Ee9d HNDrBJg7C8h1OZEqlwlATPW+WWoaz6wmFOBQsVNKrWWvyrLsl5YLzcjkhCRv1KzwxqHjY rx8/kiNPGewJOtW2zZqjAzKhrDJDrQRhhvMYBihRU6HFRCp/O1nP3tpmP4iAfLMiNXESu dqEufXtnKLUKEFxMUreP8IwluXzkJs7m+gYTGoyLtlO4yx6aDFTbW4zOnsSmZQP0wnZlt lwx5CCFIOAKt4nykRW0TtpTGlS7DdP7XYl/HuFh0mt9he23Ej/9eTuXSTlgXlAUcxIg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796325275; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=vvM53HKkcSzh64gtYMUuuIiGYRmG3pNwRFa8oy5A8HA=; b=avZVsVzvLjAiIe3RHt/9KOtGXmxj7O0XCzHikCvO/LnvpKVyLVrZCxbdg4lPU6N9eqOW 3fzW7tnCuECoZBd6n4frr4SN7P6iPFlBmtGPw1X24Y/NwDivbBN88hPDTVqD98dtQcl4o DFUUNiWgy64LmVtrkHLARmHvaB5JEhx22Gw/EIdSpqK4ZIW30sI5VoedBhFHmgAn6kb+p OCjdoWidyIDtRkz4e2vBgvg310YWxnaJI0FK5cme41dd3V4iSSh+e3lu/KrTz6NBpsfQe fbs2uRBsiQhADDVpybANnM2G6gDYWiv9OtLY4OFXxCd+8PQozMAtQCf4YRvy0ZcyE+g== 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=VZy4nluV; 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 4CDF8606A32C for ; Thu, 3 Dec 2026 19:14:34 +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=VZy4nluV Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC8251F000C2; Thu, 3 Dec 2026 19:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796325274; bh=vvM53HKkcSzh64gtYMUuuIiGYRmG3pNwRFa8oy5A8HA=; h=Date:To:From:In-Reply-To:References:Subject; b=VZy4nluVOvmT6d/TMFAme/eoFO4tUQZlIgy2U7M82R7ZyRgYKdo2NXJNypBXOTt7I w+EQgqjbr4G14yo6fQ/7/JkoB6SHkM3sRPT5V/AlI6sUz/t1AsX2gzJhtn0WfoVLtV fsD+N3GqBJY9e33GzEZCxcv3evLGFPAtS2bHn74I= Date: Thu, 03 Dec 2026 11:14:34 -0800 To: mm-commits@vger.kernel.org,mason@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261203-hugetlb_fixes_2-v2-35-9bbeabb555d2@kernel.org> References: <20261203-hugetlb_fixes_2-v2-35-9bbeabb555d2@kernel.org> Subject: + mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch added to mm-unstable branch Message-Id: <20261203191434.AC8251F000C2@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-unstable 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-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm 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: Thu, 03 Dec 2026 12:37:58 +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/20261203-hugetlb_fixes_2-v2-35-9bbeabb555d2@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: Hongfu Li Cc: Jinmeng Zhou Cc: Mina Almasry Cc: Davidlohr Bueso Cc: Naoya Horiguchi Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Mike Rapoport Cc: Michal Hocko Cc: Jonathan Corbet Cc: Shuah Khan Cc: Randy Dunlap Cc: Vivek Kasireddy Cc: Mel Gorman Cc: Hugh Dickins Cc: Baolin Wang Cc: Dave Airlie Cc: Jason Gunthorpe Cc: Andy Whitcroft Cc: Roman Gushchin Cc: Barry Song Cc: Andrea Arcangeli Cc: Lorenzo Stoakes Cc: Suren Baghdasaryan Cc: Shakeel Butt Cc: Pedro Falcato Cc: Jann Horn Cc: Guillaume Morin Cc: Yang Shi Cc: James Houghton Cc: Rik van Riel Cc: Harry Yoo Cc: Lance Yang Cc: Axel Rasmussen Cc: Peter Xu Cc: Sasha Levin Cc: Kiryl Shutsemau Cc: Christian Brauner Cc: Steven Rostedt Cc: Hongbo Li 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: Andi Kleen Cc: David Rientjes Cc: Joern Engel Cc: Aneesh Kumar K.V Cc: Gerd Hoffmann Cc: Johannes Weiner 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 @@ -6358,32 +6358,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 kfence-use-a-nofault-store-to-zero-the-guard-page.patch mm-filemap-update-the-folio-order-range-atomically.patch mm-userfaultfd-account-memory-allocated-for-unmap-events.patch mm-userfaultfd-drop-fork-context-reference-outside-event_wqhlock.patch mm-madvise-dont-declare-oom-for-madv_willneed-swapin.patch mm-mprotect-fix-unpaired-notifier-start-at-address-0.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 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 hugetlbfs-seal-shm_hugetlb-files-against-growth.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 mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch