mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
mm/hugetlb: tolerate UFFD_WP markers outside uffd-wp VMAs
UFFD PTE bit handling is a bit like swiss cheese, in particular with
recently added RWP mode. Having uffd-wp markers outside uffd-wp VMAs
already confused this code in the past and resulted in uffd-pte bits
confusing other code later.
Let's play safe and just ignore these markers in hugetlb_no_page(), not
silently propagating the uffd-wp PTE bit.
Link: https://lore.kernel.org/20261015-urgent_fixes-v1-8-42796911043b@kernel.org
Fixes: 2d427bb016 ("mm/userfaultfd: add RWP fault delivery and expose UFFDIO_REGISTER_MODE_RWP")
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Adam Litke <agl@us.ibm.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Rik van Riel <riel@surriel.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: <stable@vger.kernel.org>
This commit is contained in:
parent
811777d820
commit
c37e9d9411
|
|
@ -5981,8 +5981,11 @@ static vm_fault_t hugetlb_no_page(struct address_space *mapping,
|
|||
/*
|
||||
* If this pte was previously wr-protected, keep it wr-protected even
|
||||
* if populated.
|
||||
*
|
||||
* TODO: fix all cases where uffd-wp markers remain in VMAs that are no
|
||||
* longer registered with uffd.
|
||||
*/
|
||||
if (unlikely(pte_is_uffd_wp_marker(vmf->orig_pte)))
|
||||
if (unlikely(userfaultfd_wp(vma) && pte_is_uffd_wp_marker(vmf->orig_pte)))
|
||||
new_pte = huge_pte_mkuffd(new_pte);
|
||||
set_huge_pte_at(mm, vmf->address, vmf->pte, new_pte, huge_page_size(h));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user