• Peter Xu's avatar
    hugetlb/userfaultfd: unshare all pmds for hugetlbfs when register wp · 6dfeaff9
    Peter Xu authored
    Huge pmd sharing for hugetlbfs is racy with userfaultfd-wp because
    userfaultfd-wp is always based on pgtable entries, so they cannot be
    shared.
    
    Walk the hugetlb range and unshare all such mappings if there is, right
    before UFFDIO_REGISTER will succeed and return to userspace.
    
    This will pair with want_pmd_share() in hugetlb code so that huge pmd
    sharing is completely disabled for userfaultfd-wp registered range.
    
    Link: https://lkml.kernel.org/r/20210218231206.15524-1-peterx@redhat.comSigned-off-by: default avatarPeter Xu <peterx@redhat.com>
    Reviewed-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Axel Rasmussen <axelrasmussen@google.com>
    Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
    Cc: Kirill A. Shutemov <kirill@shutemov.name>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Adam Ruprecht <ruprecht@google.com>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: Alexey Dobriyan <adobriyan@gmail.com>
    Cc: Anshuman Khandual <anshuman.khandual@arm.com>
    Cc: Cannon Matthews <cannonmatthews@google.com>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Chinwen Chang <chinwen.chang@mediatek.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>
    Cc: Huang Ying <ying.huang@intel.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jann Horn <jannh@google.com>
    Cc: Jerome Glisse <jglisse@redhat.com>
    Cc: Lokesh Gidra <lokeshgidra@google.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: "Michal Koutn" <mkoutny@suse.com>
    Cc: Michel Lespinasse <walken@google.com>
    Cc: Mina Almasry <almasrymina@google.com>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: Oliver Upton <oupton@google.com>
    Cc: Shaohua Li <shli@fb.com>
    Cc: Shawn Anastasio <shawn@anastas.io>
    Cc: Steven Price <steven.price@arm.com>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    6dfeaff9
hugetlb.c 159 KB