[PATCH 20/46] mm/gup: fix clearing folios in memfd_pin_folios()
Samiullah Khawaja
skhawaja at google.com
Tue Oct 27 12:43:26 PDT 2026
On Tue, Oct 27, 2026 at 12:17:40AM +0100, David Hildenbrand (Arm) wrote:
>From: Chris Mason <mason at kernel.org>
>
>memfd_pin_folios() pins folios obtained directly from the page cache
>without checking whether they are uptodate. However, shmem fallocate()
>can leave newly allocated folios uncleared and not uptodate. Callers
>such as udmabuf can then expose uninitialized memory to userspace.
>
>Clear non-uptodate folios and mark them uptodate under the folio lock
>before returning them to the caller.
>
>Fix generated by an LLM and sent by Chris Mason in private.
>
>Fixes: 89c1905d9c14 ("mm/gup: introduce memfd_pin_folios() for pinning memfd folios")
>Cc: stable at vger.kernel.org
>Signed-off-by: Chris Mason <mason at kernel.org>
>[ david: simplify description and comment ]
>Signed-off-by: David Hildenbrand (Arm) <david at kernel.org>
>---
> mm/gup.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
Reviewed-by: Samiullah Khawaja <skhawaja at google.com>
Tested-by: Samiullah Khawaja <skhawaja at google.com>
Thanks,
Sami
More information about the kexec
mailing list