[PATCH v1 2/3] liveupdate: block outgoing session mutations during serialization

Pasha Tatashin pasha.tatashin at soleen.com
Tue May 5 21:32:03 PDT 2026


Introduce a 'rebooting' flag in the session header to ensure that once
serialization has started, no new outgoing session mutations (creations
or file preservations) can occur.

Fixes: 0153094d03df ("liveupdate: luo_session: add sessions support")
Reported-by: Oskar Gerlicz Kowalczuk <oskar at gerlicz.space>
Signed-off-by: Pasha Tatashin <pasha.tatashin at soleen.com>
---
 kernel/liveupdate/luo_session.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_session.c
index a3327a28fc1f..996adc995514 100644
--- a/kernel/liveupdate/luo_session.c
+++ b/kernel/liveupdate/luo_session.c
@@ -84,6 +84,7 @@
  * @header_ser: The header data of serialization array.
  * @ser:        The serialized session data (an array of
  *              `struct luo_session_ser`).
+ * @rebooting:  Indicates that the session list is being serialized.
  * @active:     Set to true when first initialized. If previous kernel did not
  *              send session data, active stays false for incoming.
  */
@@ -93,6 +94,7 @@ struct luo_session_header {
 	struct rw_semaphore rwsem;
 	struct luo_session_header_ser *header_ser;
 	struct luo_session_ser *ser;
+	bool rebooting;
 	bool active;
 };
 
@@ -147,6 +149,9 @@ static int luo_session_insert(struct luo_session_header *sh,
 
 	guard(rwsem_write)(&sh->rwsem);
 
+	if (sh->rebooting)
+		return -EBUSY;
+
 	/*
 	 * For outgoing we should make sure there is room in serialization array
 	 * for new session.
@@ -230,10 +235,15 @@ static int luo_session_release(struct inode *inodep, struct file *filep)
 static int luo_session_preserve_fd(struct luo_session *session,
 				   struct luo_ucmd *ucmd)
 {
+	struct luo_session_header *sh = &luo_session_global.outgoing;
 	struct liveupdate_session_preserve_fd *argp = ucmd->cmd;
 	int err;
 
 	guard(mutex)(&session->mutex);
+
+	if (READ_ONCE(sh->rebooting))
+		return -EBUSY;
+
 	err = luo_preserve_file(&session->file_set, argp->token, argp->fd);
 	if (err)
 		return err;
@@ -584,6 +594,8 @@ int luo_session_serialize(void)
 	int err;
 
 	guard(rwsem_write)(&sh->rwsem);
+
+	sh->rebooting = true;
 	list_for_each_entry(session, &sh->list, list) {
 		err = luo_session_freeze_one(session, &sh->ser[i]);
 		if (err)
@@ -598,6 +610,7 @@ int luo_session_serialize(void)
 	return 0;
 
 err_undo:
+	sh->rebooting = false;
 	list_for_each_entry_continue_reverse(session, &sh->list, list) {
 		i--;
 		luo_session_unfreeze_one(session, &sh->ser[i]);
-- 
2.54.0.545.g6539524ca2-goog




More information about the kexec mailing list