liveupdate: add LUO_SESSION_MAGIC magic inode type
Subsystems (3)
PATCH v2 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.
v2: apply one fix from bot review about cleanup on error path:
https://sashiko.dev/#/patchset/20260415184536.1155220-1-luca.boccassi%40gmail.com
the other comments are invalid: luo is not a kmod, and the write hooks are not set up
include/uapi/linux/magic.h | 1 + kernel/liveupdate/luo_core.c | 10 ++++- kernel/liveupdate/luo_internal.h | 2 + kernel/liveupdate/luo_session.c | 73 +++++++++++++++++++++++++++++--- 4 files changed, 80 insertions(+), 6 deletions(-)
include/uapi/linux/magic.h +1 -0
@@ -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 +9 -1
@@ -197,9 +197,17 @@ 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) +if (err) { +luo_session_fs_cleanup (); luo_global.enabled = false; + }return err; }
kernel/liveupdate/luo_internal.h +2 -0
@@ -79,6 +79,8 @@ 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 ); +void __init luo_session_fs_cleanup (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 +68 -5
103 lines not on this page · raw message
Signature · 1 line
2.47.3
Pasha Tatashin
maintainerQuoted 11 lines · On 04-17 10:44, [email protected] wrote:
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().
Hi Luca,
The patch looks good to me, but please add a self-test to selftests/liveupdate/liveupdate.c to verify that the fstat interface works as expected.
Pasha
Quoted 11 lines · Pasha Tatashin
Quoted 9 lines · On 04-17 10:44, [email protected] wrote:
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.
Quoted 8 lines
Quoted 2 lines
Add a singleton inode type with a magic value, so that we can programmatically identify a fd as a LUO session via
fstat().Hi Luca,
The patch looks good to me, but please add a self-test to
selftests/liveupdate/liveupdate.cto verify that the fstat interface works as expected.
Sure thing, added and sent v3