Live Patching
 help / color / mirror / Atom feed
From: pizza <laokz@foxmail.com>
To: Marcos Paulo de Souza <mpdesouza@suse.com>,
	live-patching@vger.kernel.org
Subject: Re: RFC: another way to make livepatch
Date: Wed, 10 Jan 2024 22:06:39 +0800	[thread overview]
Message-ID: <tencent_A370A7F1740CD64A13DA74F221EB8B9AC609@qq.com> (raw)
In-Reply-To: <761e2fc21e72576a4704572b50d9fc5b4a1cb9e1.camel@suse.com>

On Wed, 2024-01-10 at 08:52 -0300, Marcos Paulo de Souza wrote:
> On Thu, 2023-12-21 at 22:06 +0800, laokz wrote:
> > Hi,
> > 
> > Is it off-topic talking about livepatch making tool? I tried another
> > way and
> > want to get your expert opinion if there any fatal pitfall.
> 
> I don't think it's out of scope, but what exactly you mean by "another

Thanks.

> way to make livepatch"? You would like to know about different
> approaches like source-based livepatch compared to kpatch, or you mean

Yes, exactly. Inspired by kpatch, I tried to make livepatch on source level
to avoid difficult binary hacking, just like what we did normal module
development. The main idea is similar to some topics of this mail list,

1. Write livepatch-sample.c stylish source code, put all needed non-
export/non-include symbols(I call them KLPSYMs) declarations in file.
2. Generate KLPSYMs position information through kallsyms etc.
3. `KBUILD_MODPOST_WARN=1 make` to build a "partial linked" .ko.
4. Use a klp-convert like tool to transform the KLPSYMs.

For simple patch, hand-write source might be easy though a little time
consuming. I used libclang to auto abbreviate livepatch source[1]. 

The main obstacle, IMO, is "how to determine non-included local symbols",
because they might be inlined, optimized out, duplicate names, mangled
names, and because kallsyms, vmlinux .symtab less some verbose information.
In my toy, I used DWARF along with kallsyms to try to verify all of them. 

But now I realized that DWARF might be the fatal pitfall. That's a pity. I
still get hope that's not too bad:)

[1] https://gitee.com/laokz/klpmake
[2] mirror: https://github.com/laokz/klpmake

> something different?
> 
> Thanks!
> 
> > 
> > Thanks.
> > 
> > laokz
> > 
> > 
> 
> 


  reply	other threads:[~2024-01-10 14:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 14:06 RFC: another way to make livepatch laokz
2024-01-10 11:52 ` Marcos Paulo de Souza
2024-01-10 14:06   ` pizza [this message]
2024-01-10 16:28     ` Marcos Paulo de Souza
2024-01-11 14:52       ` laokz

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=tencent_A370A7F1740CD64A13DA74F221EB8B9AC609@qq.com \
    --to=laokz@foxmail.com \
    --cc=live-patching@vger.kernel.org \
    --cc=mpdesouza@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox