Skip to contentSkip to conversation

liveupdate: add LUO_SESSION_MAGIC magic inode type

PATCH Superseded [email protected] 1 participant 1 message Apr 15

Subsystems (3)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 liveupdate: add LUO_SESSION_MAGIC magic inode type

From: Luca Boccassi <[email protected]>

In userspace when managing LUO sessions we want to be able to identify a FD as a LUO session, in order to be able to do the special handling that they require in order to function as intended on kexec.

Currently this requires scraping procfs and doing string matching on the prefix of the dname, which is not an ideal interface.

Add a singleton inode type with a magic value, so that we can programmatically identify a fd as a LUO session via fstat().

---
This was requested by Lennart and Christian when discussing integration with systemd for LUO management.

 include/uapi/linux/magic.h       |  1 +
 kernel/liveupdate/luo_core.c     |  6 +++
 kernel/liveupdate/luo_internal.h |  1 +
 kernel/liveupdate/luo_session.c  | 67 +++++++++++++++++++++++++++++---
 4 files changed, 70 insertions(+), 5 deletions(-)
include/uapi/linux/magic.h +1 -0
index 4f2da935a76cc..4f51005522ffe 100644
@@ -105,5 +105,6 @@
 #define PID_FS_MAGIC		0x50494446	/* "PIDF" */
 #define GUEST_MEMFD_MAGIC	0x474d454d	/* "GMEM" */
 #define NULL_FS_MAGIC		0x4E554C4C	/* "NULL" */
+#define LUO_SESSION_MAGIC	0x4c554f53	/* "LUOS" */
 
 #endif /* __LINUX_MAGIC_H__ */
kernel/liveupdate/luo_core.c +6 -0
index dda7bb57d421c..ec00c681a0f50 100644
@@ -197,6 +197,12 @@ static int __init luo_late_startup(void)
 	if (!liveupdate_enabled())
 		return 0;
 
+	err = luo_session_fs_init();
+	if (err) {
+		luo_global.enabled = false;
+		return err;
+	}
+
 	err = luo_fdt_setup();
 	if (err)
 		luo_global.enabled = false;
kernel/liveupdate/luo_internal.h +1 -0
index 8083d8739b093..223a9dc1ca29b 100644
@@ -79,6 +79,7 @@ struct luo_session {
 
 int luo_session_create(const char *name, struct file **filep);
 int luo_session_retrieve(const char *name, struct file **filep);
+int __init luo_session_fs_init(void);
 int __init luo_session_setup_outgoing(void *fdt);
 int __init luo_session_setup_incoming(void *fdt);
 int luo_session_serialize(void);
kernel/liveupdate/luo_session.c +62 -5

97 lines not on this page · raw message

Signature · 1 line
2.47.3