[RFC PATCH 1/6] liveupdate: luo_file: look up outgoing tokens by id
From: Pratyush Yadav
Date: Wed Sep 23 2026 - 18:51:23 EST
From: "Pratyush Yadav (Google)" <pratyush@xxxxxxxxxx>
liveupdate_get_token_outgoing() is used to look up tokens of
dependencies. It does the search based on struct file. LUO preserves
resources; the files are only handles to those resources.
LUO provides file handlers a ->get_id() callback that can return the
unique identifier of a resource. LUO uses it to ensure the same resource
can't be preserved twice if it can be referred to by multiple files. The
default ID is the struct file, but file handlers can implement the
callback and return something else. For example, memfd returns the inode
of the file, not the struct file itself.
Use ID to look up dependencies in liveupdate_get_token_outgoing()
instead of struct file. This allows the lookup to work with handlers
that use things other than the struct file.
Signed-off-by: Pratyush Yadav (Google) <pratyush@xxxxxxxxxx>
---
include/linux/liveupdate.h | 6 +++---
kernel/liveupdate/luo_file.c | 21 ++++++++++++---------
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/include/linux/liveupdate.h b/include/linux/liveupdate.h
index 6051abc0612c..1cddbab50b98 100644
--- a/include/linux/liveupdate.h
+++ b/include/linux/liveupdate.h
@@ -253,9 +253,9 @@ void liveupdate_flb_put_outgoing(struct liveupdate_flb *flb);
int liveupdate_get_file_incoming(struct liveupdate_session *s, u64 token,
struct file **filep);
-/* Get a token for an outgoing file, or -ENOENT if file is not preserved */
+/* Get a token for a preserved object, or -ENOENT if it is not preserved */
int liveupdate_get_token_outgoing(struct liveupdate_session *s,
- struct file *file, u64 *tokenp);
+ unsigned long id, u64 *tokenp);
#else /* CONFIG_LIVEUPDATE */
@@ -316,7 +316,7 @@ static inline int liveupdate_get_file_incoming(struct liveupdate_session *s,
}
static inline int liveupdate_get_token_outgoing(struct liveupdate_session *s,
- struct file *file, u64 *tokenp)
+ unsigned long id, u64 *tokenp)
{
return -EOPNOTSUPP;
}
diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c
index a39992da504f..51817d202ce2 100644
--- a/kernel/liveupdate/luo_file.c
+++ b/kernel/liveupdate/luo_file.c
@@ -950,29 +950,32 @@ void liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh)
}
/**
- * liveupdate_get_token_outgoing - Get the token for a preserved file.
+ * liveupdate_get_token_outgoing - Get the token for a preserved object.
* @s: The outgoing liveupdate session.
- * @file: The file object to search for.
+ * @id: The identifier of the preserved object to search for, as returned
+ * by the owning handler's ->get_id().
* @tokenp: Output parameter for the found token.
*
- * Searches the list of preserved files in an outgoing session for a matching
- * file object. If found, the corresponding user-provided token is returned.
+ * Searches the list of preserved files in an outgoing session for an object
+ * with a matching identifier. If found, the corresponding user-provided token
+ * is returned.
*
- * This function is intended for in-kernel callers that need to correlate a
- * file with its liveupdate token.
+ * For handlers that do not implement ->get_id() use the 'struct file' pointer
+ * as their identifier.
*
* Context: It must be called with session mutex acquired.
- * Return: 0 on success, -ENOENT if the file is not preserved in this session.
+ * Return: 0 on success, -ENOENT if no such object is preserved in this
+ * session.
*/
int liveupdate_get_token_outgoing(struct liveupdate_session *s,
- struct file *file, u64 *tokenp)
+ unsigned long id, u64 *tokenp)
{
struct luo_file_set *file_set = luo_file_set_from_session_locked(s);
struct luo_file *luo_file;
int err = -ENOENT;
list_for_each_entry(luo_file, &file_set->files_list, list) {
- if (luo_file->file == file) {
+ if (luo_get_id(luo_file->fh, luo_file->file) == id) {
if (tokenp)
*tokenp = luo_file->token;
err = 0;
--
2.56.0.rc1.310.g51773c2048-goog