In the Linux kernel, the following vulnerability has been resolved:
hugetlb, userfaultfd: fix reservation restore on userfaultfd error
Currently in the iscontinue case in hugetlbmcopyatomicpte(), if we bail out using "goto outreleaseunlock;" in the cases where idx >= size, or !hugeptenone(), the code will detect that newpagecachepage == false, and so call restorereserveonerror(). In this case I see restorereserveonerror() delete the reservation, and the following call to removeinodehugepages() will increment h->resv_hugepages causing a 100% reproducible leak.
We should treat the iscontinue case similar to adding a page into the pagecache and set newpagecachepage to true, to indicate that there is no reservation to restore on the error path, and we need not call restorereserveonerror(). Rename newpagecachepage to pageinpagecache to make that clear.