Live Patching
 help / color / mirror / Atom feed
* [RFC] Add target module check before livepatch module loading
@ 2025-03-07  3:12 zhang warden
  2025-03-07 13:52 ` Petr Mladek
  0 siblings, 1 reply; 7+ messages in thread
From: zhang warden @ 2025-03-07  3:12 UTC (permalink / raw)
  To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
	Joe Lawrence, live-patching

I had faced a scenario like this:

There is a fuse.ko which is built as module of kernel source.
However, our team maintain the fuse as oot module.

There is a bug of (name it as B1) the original fuse.ko. 
And our team fix B1 of fuse.ko as release it as oot module fuse_o1.ko.
Our system loaded fuse_o1.ko. Now, another team made a livepatch module base on fuse.ko to fix B2 bug.
They load this livepatch_fuse.ko to the system, it fixed B2 bug, however, the livepatch_fuse.ko revert the fix of fuse_o1.ko.

It expose the B1 bug which is already fix in fuse_o1.ko
The exposed B1 bug make fault to our cluster, which is a bad thing :(

This  scenario shows the vulnerable of live-patching when handling 
out-of-tree module.

I have a original solution to handle this:
    • In kpatch-build, we would record the patched object, take the object of ko as a list of parameters.
    • Pass this ko list as parameter to create-klp-moudle.c
    • For each patched ko object, we should read its srcversion from the original module. If we use --oot-module, we would read the srcversion from the oot moudle version.
    • Store the target srcversion to a section named '.klp.target_srcversions'
    • When the kpatch module loading, we shoud check if section '.klp.target_srcversion' existed. If existed, we should check srcversion of the patch target in the system match our recorded srcversion or not. If thet are not match, refuse to load it. This can make sure the livepatch module would not load the wrong target.
This function can avoid livepatch from patching the wrong version of the function.

The original discussion can be seem on [1]. (Discussion with Joe Lawrence)

After the discussion, we think that the actual enforcement of this seems like a job for kernel/livepatch/core.c.
Or it should be the process of sys call `init_module` when loading a module.

I am here waiting for Request For Comment. Before I do codes.

Thanks~~ ;)
Wardenjohn.

[1]: https://github.com/dynup/kpatch/issues/1435

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-12  3:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-07  3:12 [RFC] Add target module check before livepatch module loading zhang warden
2025-03-07 13:52 ` Petr Mladek
2025-03-10  2:22   ` zhang warden
2025-03-10 15:48     ` Petr Mladek
2025-03-11  3:53       ` zhang warden
2025-03-11 12:25         ` Petr Mladek
2025-03-12  3:17           ` zhang warden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox