Re: [PATCH] mm/memfd_luo: report error when restoring a folio fails mid-loop

From: Mike Rapoport

Date: Tue Apr 28 2026 - 10:40:42 EST


From: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>

On Wed, 15 Apr 2026 06:23:00 +0100, David Carlier wrote:
> memfd_luo_retrieve_folios() initialises err to -EIO, but the per-iteration
> calls to mem_cgroup_charge(), shmem_add_to_page_cache() and
> shmem_inode_acct_blocks() reuse and overwrite err. Once any iteration
> completes successfully, err becomes zero.
>
> If a later iteration's kho_restore_folio() returns NULL, the failure path
> jumps to put_folios without resetting err, so the function returns 0.
> The caller memfd_luo_retrieve() then takes the success path, sets
> args->file and reports the restore as successful, leaving userspace with
> a partially populated memfd and no indication that anything went wrong.
>
> [...]

Applied to fixes branch of liveupdate/linux.git tree, thanks!

[1/1] mm/memfd_luo: report error when restoring a folio fails mid-loop
commit: 0fb1daf0b78d0e23b63b6b65de56d4a3fd83bc14

tree: https://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux
branch: fixes

--
Sincerely yours,
Mike.