Fix multiple bugs that occur when using memfd_pin_folios with hugetlb pages and THP. The hugetlb bugs only bite when the page is not yet faulted in when memfd_pin_folios is called. The THP bug bites when the starting offset passed to memfd_pin_folios is not huge page aligned. See the commit messages for details. Steve Sistare (5): mm/filemap: fix filemap_get_folios_contig THP panic mm/hugetlb: fix memfd_pin_folios free_huge_pages leak mm/hugetlb: fix memfd_pin_folios resv_huge_pages leak mm/gup: fix memfd_pin_folios hugetlb page allocation mm/gup: fix memfd_pin_folios alloc race panic include/linux/hugetlb.h | 10 ++++++++++ mm/filemap.c | 4 ++++ mm/gup.c | 5 ++++- mm/hugetlb.c | 17 +++++++++++++++++ mm/memfd.c | 15 +++++++++------ 5 files changed, 44 insertions(+), 7 deletions(-) -- 1.8.3.1