From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796007110; b=KSs59uB5mizSdYn3SuESZsnubj5RerLp3Wbq0w/tgfVSvUNY2YP1QuTim9flCPIkEHtR YAatbC2ztciy79qNsk4ZfKUyxt7fy18yLWRbaxdbIXL6UBwEb9mwGvD3M7nucY2p/6QZG lxLjR+ZKqoIOjNadCr3OZPDQzf52KUIBsKMXFOt8Utv78RuHYJYgYhq5PxlccGMDcUjdf yjDfn68tgB9jxGh250pMb4XGtM2Nox/CgD6caoITDO1f2Jv43Yrb8aFSojX6PatwDBu1T QFJceeiVbL4pwznCl6LLpe82LDqkwQWNXTAzwuBPcv1/c49zORyTa4vfVgPh6jNMEAg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796007110; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=3y4U6/UjlCEQLHqBXRx4Uuwjm1hJFbwijJu6b7m9Zoo=; b=ynwgCYEG5Nv5me4s42Dm/SUufr3YLnzoNP9b9Mw+YL8AJwa1IQ5Ul5zKxyTKul2OHtjd E6hPwAKuK7o477pl5wm7dfWRi2F2URWd0Qszie+igd6vFfpzWB7HXSiFyw+ZS5ScHO3To c7MBY/C60JFxwVwO1O2T9iyFt1EcyFOygdXAs4Mu2RcTR5CFTBwffdmjT9NUap+ajWULl R7hKH5ARxe0nE0I/1KHV6gvX5e6CPU1wR44AL0MBtoBKSgBWrLLXbfcj9BVenoQCV3S/m iIf10Tq56BN067nqRKq/Dzqp++kR949ghKDjD6rgA5fYBWKvBid2vlU7q8bbDlkup0w== 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=D3yydcbQ; 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 CF37A606A31C for ; Mon, 30 Nov 2026 02:51:50 +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=D3yydcbQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B2E61F00896; Mon, 30 Nov 2026 02:51:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796007110; bh=3y4U6/UjlCEQLHqBXRx4Uuwjm1hJFbwijJu6b7m9Zoo=; h=Date:To:From:In-Reply-To:References:Subject; b=D3yydcbQctqB8d+b+P5wCRLOuOxCXrljDLafvNM1vVFquMZxlGyzyGk1iuGrJnH// ZK56KU7fYlLTFABTscqgH68gMcSdXHs0G5o0hbmG/M+73GnDu7LcJzmBaKzn0/g3Bg BfAfdbe+Ag4W/JIiifO8ZMJ6nWwLpcnLhG7d6E4w= Date: Sun, 29 Nov 2026 18:51:49 -0800 To: mm-commits@vger.kernel.org,mason@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261125-hugetlb_fixes_2-v1-2-db27fd2f71a8@kernel.org> References: <20261125-hugetlb_fixes_2-v1-2-db27fd2f71a8@kernel.org> Subject: + mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy.patch added to mm-new branch Message-Id: <20261130025150.2B2E61F00896@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: fix truncated copy result in UFFDIO_COPY has been added to the -mm mm-new branch. Its filename is mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next 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: fix truncated copy result in UFFDIO_COPY Date: Wed, 25 Nov 2026 23:33:00 +0100 Patch series "mm/hugetlb: various fixes (2)". Some more hugetlb fixes, this time not as horrible and confusing stuff as last time: - Patch #1 - #17: a bunch of non-urgent fixes - Patch #18 - #19: two related improvements - Patch #21: an RFC for a hugetlb cgroup fix This patch (of 20): Folios that span more bytes than can fit into an unsigned integer (e.g., 16 GiB folios on arm64) are problematic with UFFDIO_COPY: the result from copy_folio_from_user() can be truncated, possibly indicating success instead of an error. We will then continue with the folio that has stale data, and make it accessible to user space. For example, if copy_folio_from_user() fails such that the number of bytes not copied is a multiple of 4 GiB, we'll get an effective ret == 0. Let's fix it by simply testing the return value directly. This has medium urgency, as it's an information leak. [david@kernel.org: cleanup code and description] Link: https://patch.msgid.link/20261125-hugetlb_fixes_2-v1-2-db27fd2f71a8@kernel.org Fixes: 8fb5debc5fcd ("userfaultfd: hugetlbfs: add hugetlb_mcopy_atomic_pte for userfaultfd support") Signed-off-by: Chris Mason Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Andrew Morton Reviewed-by: Oscar Salvador (SUSE) Reviewed-by: Hongfu Li Reviewed-by: Muchun Song (ByteDance) Cc: Oscar Salvador Cc: Jinmeng Zhou Cc: Andrea Arcangeli Cc: Mike Kravetz Cc: Naoya Horiguchi Cc: Hugh Dickins Cc: Baolin Wang Cc: Dave Airlie Cc: Vivek Kasireddy Cc: Gerd Hoffmann Cc: Mike Rapoport Cc: Mel Gorman Cc: Dave McCracken Cc: Andy Whitcroft Cc: Adam Litke Cc: Lorenzo Stoakes Cc: Rik van Riel Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Harry Yoo Cc: Jann Horn Cc: Lance Yang Cc: James Houghton Cc: Yang Shi Cc: Suren Baghdasaryan Cc: Shakeel Butt Cc: Pedro Falcato 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: Wanpeng Li Cc: Andi Kleen Cc: Kenneth W Chen Cc: Michal Hocko Cc: David Rientjes Cc: Joern Engel Cc: Jonathan Corbet Cc: Shuah Khan Cc: Randy Dunlap Cc: Aneesh Kumar K.V Cc: KAMEZAWA Hiroyuki Cc: Kiryl Shutsemau Cc: Sasha Levin Cc: Guillaume Morin Cc: Wanpeng Li Cc: Jason Gunthorpe Cc: luojiajun Cc: Josef Bacik Cc: Daehyeon Ko <4ncienth@gmail.com> Cc: Ackerley Tng Cc: Jiaqi Yan Cc: mm/hugetlb.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- a/mm/hugetlb.c~mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy +++ a/mm/hugetlb.c @@ -6545,11 +6545,8 @@ int hugetlb_mfill_atomic_pte(pte_t *dst_ goto out; } - ret = copy_folio_from_user(folio, (const void __user *) src_addr, - false); - /* fallback to copy_from_user outside mmap_lock */ - if (unlikely(ret)) { + if (unlikely(copy_folio_from_user(folio, (const void __user *)src_addr, false))) { ret = -ENOENT; /* Free the allocated folio which may have * consumed a reservation. _ 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 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 kfence-use-a-nofault-store-to-zero-the-guard-page.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 mm-hugetlb-unshare-pmds-of-a-split-vma-if-allocating-its-lock-fails.patch mm-hugetlb_cgroup-track-in-use-folios-per-cgroup.patch hugetlbfs-seal-shm_hugetlb-files-against-growth.patch mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch