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=1796325213; b=M5TSHLwLuDIEWfR8uedq4JON1d8wbXjf41xwiNc3Qk5YT0E6YUlnu4tRQGcoyeWMYbt/ DY0Sk7VY7bl66qNhObA6jmBTlZP/sC51n1j62tAcTe4SLdsVNLcucLNqNb/9/z/Svxg5t IdsydamDFYuobA0AC2+LcBuuKSubvrF0L6t+XVa2eQ3I3IeNV/REGfxjs38SPpc+KVIiI 0BqRvPaX+DVfI95S1C1AQGVRjI6u+Huvzf/YIKOqS4e+WqXw7Eo5xnNrzT2f99AZQOcO9 YnTqjHCTwVkr92u1DCOxAvbHs3F8MkAX9qPxghNRuvC1sxGeClWsMgeQZw3pm9tWVTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796325213; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=5NsGBy7QrE6BuSnWOtXfUqoGVTgWlHTQ8CRCgx8IXr0=; b=k8ocWul1Jog26IJ2psv43yWM1lFSTPpcRsrP0aJ/9MX8/elG5xF7bhTclvLyKRr37ffy Ogbn3xaQr8UZ5CGmAnpiPCsBS0bOXgZL9R2EZBiM3rvQ+Q97+ZI+n4dMisjZrGbhC4RW8 mHwvIg6QxPptmTTtYEFyY6I89C1ZDmPxbAKWkF5RIw1iX/cRiRyqxg85dW1JwTmv/weJe zL2CWsBQH5VXUqWIomlbMTHDflHo6KAI305sXcygFu2z7XNWQuzFHhIPCb1kif7c0jN7U ynwjH8gflbq21agt62n8k2lZwGnbA6gj4N9rgTErvW/wGQaoht17rC+JaguR9zwjQDA== 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=bSRCDZd8; 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 B842D606A322 for ; Thu, 3 Dec 2026 19:13:33 +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=bSRCDZd8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8285E1F000C2; Thu, 3 Dec 2026 19:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796325213; bh=5NsGBy7QrE6BuSnWOtXfUqoGVTgWlHTQ8CRCgx8IXr0=; h=Date:To:From:In-Reply-To:References:Subject; b=bSRCDZd8Na5WEzuWEH72Njj1mC24tk4vFq6HpX1FptHz03CvhAjTOArwmI4rSqcuA WEkq5DQATvjmu2WVpq5nLXdlc/tfaLYPczSdzM62P4X8QOvwxM5pplo8QGg50EvLpV b3D57quNmXJUkP5XwUhK/WAESXwRxJyEuQHa4yho= Date: Thu, 03 Dec 2026 11:13:33 -0800 To: mm-commits@vger.kernel.org,mason@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261203-hugetlb_fixes_2-v2-12-9bbeabb555d2@kernel.org> References: <20261203-hugetlb_fixes_2-v2-12-9bbeabb555d2@kernel.org> Subject: + mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy.patch added to mm-unstable branch Message-Id: <20261203191333.8285E1F000C2@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-unstable 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-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm 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: Thu, 03 Dec 2026 12:37:35 +0100 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/20261203-hugetlb_fixes_2-v2-12-9bbeabb555d2@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: Muchun Song (ByteDance) Reviewed-by: Oscar Salvador (SUSE) Reviewed-by: Hongfu Li Cc: Jinmeng Zhou Cc: Mina Almasry Cc: Davidlohr Bueso Cc: Naoya Horiguchi Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Mike Rapoport Cc: Michal Hocko Cc: Jonathan Corbet Cc: Shuah Khan Cc: Randy Dunlap Cc: Vivek Kasireddy Cc: Mel Gorman Cc: Hugh Dickins Cc: Baolin Wang Cc: Dave Airlie Cc: Jason Gunthorpe Cc: Andy Whitcroft Cc: Roman Gushchin Cc: Barry Song Cc: Andrea Arcangeli Cc: Lorenzo Stoakes Cc: Suren Baghdasaryan Cc: Shakeel Butt Cc: Pedro Falcato Cc: Jann Horn Cc: Guillaume Morin Cc: Yang Shi Cc: James Houghton Cc: Rik van Riel Cc: Harry Yoo Cc: Lance Yang Cc: Axel Rasmussen Cc: Peter Xu Cc: Sasha Levin Cc: Kiryl Shutsemau Cc: Christian Brauner Cc: Steven Rostedt Cc: Hongbo Li 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: Andi Kleen Cc: David Rientjes Cc: Joern Engel Cc: Aneesh Kumar K.V Cc: Gerd Hoffmann Cc: Johannes Weiner 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 @@ -6581,11 +6581,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 kfence-use-a-nofault-store-to-zero-the-guard-page.patch mm-filemap-update-the-folio-order-range-atomically.patch mm-userfaultfd-account-memory-allocated-for-unmap-events.patch mm-userfaultfd-drop-fork-context-reference-outside-event_wqhlock.patch mm-madvise-dont-declare-oom-for-madv_willneed-swapin.patch mm-mprotect-fix-unpaired-notifier-start-at-address-0.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 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 hugetlbfs-seal-shm_hugetlb-files-against-growth.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 mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch