Re: [PATCH v2 12/35] mm/hugetlb: fix truncated copy result in UFFDIO_COPY
From: Jose A. Perez de Azpillaga
Date: Fri Dec 04 2026 - 05:53:32 EST
On 12/3/26 12:37 PM, David Hildenbrand (Arm) wrote:
> From: Chris Mason <mason@xxxxxxxxxx>
>
> 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.
>
> Fixes: 8fb5debc5fcd ("userfaultfd: hugetlbfs: add hugetlb_mcopy_atomic_pte for userfaultfd support")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Chris Mason <mason@xxxxxxxxxx>
> [ david: cleanup code and description ]
> Reviewed-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>
> Reviewed-by: Oscar Salvador (SUSE) <osalvador@xxxxxxxxxx>
> Reviewed-by: Hongfu Li <lihongfu@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
LGTM:
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
--
cheers,
jose a. p-a