From: Pratyush Yadav <pratyush@kernel.org>
To: David Carlier <devnexen@gmail.com>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>,
Mike Rapoport <rppt@kernel.org>,
Pratyush Yadav <pratyush@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Chenghao Duan <duanchenghao@kylinos.cn>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/memfd_luo: report error when restoring a folio fails mid-loop
Date: Thu, 16 Apr 2026 09:44:37 +0000 [thread overview]
Message-ID: <2vxzik9r6xyy.fsf@kernel.org> (raw)
In-Reply-To: <20260415052300.362539-1-devnexen@gmail.com> (David Carlier's message of "Wed, 15 Apr 2026 06:23:00 +0100")
On Wed, Apr 15 2026, 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.
>
> Set err to -EIO in the kho_restore_folio() failure branch so the error
> is propagated to the caller.
>
> Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Please add these when applying:
Cc: stable@vger.kernel.org
Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd")
[...]
--
Regards,
Pratyush Yadav
prev parent reply other threads:[~2026-04-16 9:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 5:23 David Carlier
2026-04-16 9:44 ` Pratyush Yadav [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2vxzik9r6xyy.fsf@kernel.org \
--to=pratyush@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=devnexen@gmail.com \
--cc=duanchenghao@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=rppt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox