From: Petr Mladek <pmladek@suse.com>
To: Harry Hsu <x90613@gmail.com>
Cc: jpoimboe@kernel.org, mbenes@suse.cz, joe.lawrence@redhat.com,
jikos@kernel.org, live-patching@vger.kernel.org,
shuah@kernel.org, song@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 0/5] livepatch: Fail object initialization on duplicate patched function
Date: Fri, 30 Oct 2026 10:15:04 +0100 [thread overview]
Message-ID: <auRgGK3aQyv7tF9J@pathway.suse.cz> (raw)
In-Reply-To: <20261028164649.337479-1-x90613@gmail.com>
On Thu 2026-10-29 00:46:49, Harry Hsu wrote:
> On Fri 2026-10-23, Petr Mladek wrote:
> > I wonder how to move forward with this patchset. There seems to be
> > three unresolved problems:
> >
> > 1. How to handle aliased functions when replacing two livepatches
> > with aliased symbols, aka two NOPs on the same stack [1].
> >
> > My take: I would fix this later on top of scoped atomic replace.
> > The aliased symbols should conflict.
> > 2. Fix the low-level __write_relocate_add() to clean its own
> > mess on failure.
> >
> > My take: I would fix this a follow up patch.
> >
> > 3. Better describe the purpose of klp_write_object_relocs_limited().
> > Or clean its own mess a better way (code duplication)?
> >
> > My take: This requires v5.
>
> For 1, I have a proposal to create only one NOP in the first place,
> as in your solution 1 from the earlier mail.
>
>
> Recap: The problem
> -----------
>
> Take two livepatches that are already loaded:
> A patches __do_sys_fork
> B patches __x64_sys_fork (same address as __do_sys_fork)
>
> and an atomic replace livepatch C that patches neither of them.
> klp_add_nops() finds the functions by name and sympos only, so C
> inherits two NOPs. Both resolve to the same address and end up on
> the same ops->func_stack: [A, B, nop1, nop2]. When the transition
> is reverted, the stack goes from nop2 to nop1 instead of back to B.
>
>
> Proposal
> --------
>
> klp_add_nops() runs from klp_init_patch() before klp_init_object(),
> so the new NOPs have no address yet. But func->old_func of the old
> livepatches is already resolved when their object is loaded.
Hmm, this is not good. It would be better to have an universal
solution which would work even when the livepatched object (module)
gets loaded later.
A solution might be to detect this in klp_init_object_loaded()
and free the duplicated NOP there. I am not 100% sure that this
would work but it might be worth investigating.
Best Regards,
Petr
prev parent reply other threads:[~2026-10-30 9:15 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 12:03 Petr Mladek
2026-09-08 12:03 ` [PATCH v4 1/5] " Petr Mladek
2026-09-08 12:17 ` sashiko-bot
2026-09-08 13:02 ` Petr Mladek
2026-09-18 12:54 ` Miroslav Benes
2026-09-30 14:11 ` [PATCH v4 1/3] " Harry Hsu
2026-10-01 4:32 ` [PATCH v4 1/5] " Harry Hsu
2026-10-23 14:17 ` Petr Mladek
2026-10-27 14:02 ` Miroslav Benes
2026-09-08 12:03 ` [PATCH v4 2/5] selftests/livepatch: Test rejection of aliased symbols in one object Petr Mladek
2026-09-18 13:40 ` Miroslav Benes
2026-09-08 12:03 ` [PATCH v4 3/5] livepatch: Move code for updating livepatch object relocations Petr Mladek
2026-09-18 13:40 ` Miroslav Benes
2026-09-08 12:03 ` [PATCH v4 4/5] livepatch: Clear relocations when klp_apply_object_relocs() fails Petr Mladek
2026-09-08 12:18 ` sashiko-bot
2026-09-08 13:29 ` Petr Mladek
2026-09-18 13:59 ` Miroslav Benes
2026-09-18 14:05 ` Miroslav Benes
2026-10-23 15:05 ` Petr Mladek
2026-10-27 14:21 ` Miroslav Benes
2026-09-08 12:03 ` [PATCH v4 5/5] livepatch: Clean up klp_init_object_loaded() when fails Petr Mladek
2026-09-08 12:25 ` sashiko-bot
2026-09-08 13:32 ` Petr Mladek
2026-09-18 14:07 ` Miroslav Benes
2026-10-23 15:19 ` [PATCH v4 0/5] livepatch: Fail object initialization on duplicate patched function Petr Mladek
2026-10-28 16:46 ` Harry Hsu
2026-10-30 9:15 ` Petr Mladek [this message]
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=auRgGK3aQyv7tF9J@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=x90613@gmail.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
all inboxes | Powered by JetHome®