Re: [PATCH v3 05/10] liveupdate: Don't WARN if tracking a retrieved file fails

From: Pratyush Yadav

Date: Wed Nov 04 2026 - 09:36:06 EST


On Tue, Nov 03 2026, David Matlack wrote:

> Handle a failure to add a retrieved file to luo_preserved_files instead
> of triggering a WARN_ON(). Make the failure permanent, and keep the file
> until the file set is finished, like any other retrieved file.
>
> xa_insert() can fail with -ENOMEM, and userspace can trigger that with
> LIVEUPDATE_SESSION_RETRIEVE_FD, so warning about it lets userspace crash
> systems with panic_on_warn.
>
> The handler has already consumed the preserved state when this happens,
> so the retrieve can't be retried. Keeping the file ensures that its
> resources are not released before the file set is finished. Finishing
> the file set then erases the file from luo_preserved_files, which does
> nothing for a file that was never added.
>
> Fixes: 00d0b372374f ("liveupdate: prevent double management of files")
> Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx>
> Acked-by: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx>
> ---
> kernel/liveupdate/luo_file.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c
> index 908ae124ea5e..5a82e45b9062 100644
> --- a/kernel/liveupdate/luo_file.c
> +++ b/kernel/liveupdate/luo_file.c
> @@ -684,14 +684,25 @@ int luo_retrieve_file(struct luo_file_set *file_set, u64 token, u64 arg,
> return err;
> }
>
> + err = xa_insert(&luo_preserved_files,
> + luo_get_id(luo_file->fh, args.file), args.file,
> + GFP_KERNEL);
> + if (err) {

I think you should do a WARN_ON_ONCE(err == -EBUSY) here. Because if
someone can somehow retrieve the same file twice, something really bad
has happened and must be reported.

> + /*
> + * The handler has consumed the preserved state, so the retrieve
> + * can't be retried. Keep the file until the file set is
> + * finished, so that its resources are released at the same
> + * time as those of other retrieved files.
> + */
> + luo_file->file = args.file;
> + luo_file->retrieve_status = err;
> + return err;
> + }
> +
> luo_file->file = args.file;
> /* Get reference so we can keep this file in LUO until finish */
> get_file(luo_file->file);
>
> - WARN_ON(xa_insert(&luo_preserved_files,
> - luo_get_id(luo_file->fh, luo_file->file),
> - luo_file->file, GFP_KERNEL));
> -
> *filep = luo_file->file;
> luo_file->retrieve_status = 1;

--
Regards,
Pratyush Yadav