[PATCH v2 05/10] liveupdate: Don't WARN if tracking a retrieved file fails
David Matlack
dmatlack at google.com
Thu Oct 22 15:50:30 PDT 2026
Handle a failure to add a retrieved file to luo_preserved_files instead
of triggering a WARN_ON(). 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 make the failure permanent. Keep the file until the file set is
finished, like any other retrieved file, so that its resources are not
released before then. 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")
Assisted-by: LLM
Signed-off-by: David Matlack <dmatlack at google.com>
---
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) {
+ /*
+ * 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;
--
2.56.0.257.gf7497c7d27-goog
More information about the kexec
mailing list