All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhang warden <zhangwarden@gmail.com>
To: Josh Poimboeuf <jpoimboe@kernel.org>,
	Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
	Petr Mladek <pmladek@suse.com>,
	Joe Lawrence <joe.lawrence@redhat.com>,
	live-patching@vger.kernel.org
Subject: [RFC] Add target module check before livepatch module loading
Date: Fri, 7 Mar 2025 11:12:18 +0800	[thread overview]
Message-ID: <C746373C-96ED-47EE-94F2-00E930BE2E8B@gmail.com> (raw)

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

             reply	other threads:[~2025-03-07  3:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07  3:12 zhang warden [this message]
2025-03-07 13:52 ` [RFC] Add target module check before livepatch module loading 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C746373C-96ED-47EE-94F2-00E930BE2E8B@gmail.com \
    --to=zhangwarden@gmail.com \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.