Live Patching
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: jpoimboe@kernel.org, jikos@kernel.org, mbenes@suse.cz,
	joe.lawrence@redhat.com, song@kernel.org,
	live-patching@vger.kernel.org
Subject: Re: [PATCH v3 3/7] livepatch: Support scoped atomic replace using replace_set
Date: Wed, 10 Jun 2026 11:48:30 +0200	[thread overview]
Message-ID: <aiky7hr6sFMjXD-P@pathway.suse.cz> (raw)
In-Reply-To: <CALOAHbD6q0By=NZ2Lk0SAFjzpJ_=AKPLdVqd5T09PiKsppiwOA@mail.gmail.com>

On Wed 2026-06-10 11:24:57, Yafang Shao wrote:
> On Wed, Jun 10, 2026 at 12:00 AM Petr Mladek <pmladek@suse.com> wrote:
> >
> > On Sun 2026-06-07 21:16:55, Yafang Shao wrote:
> > > Convert the replace attribute from a boolean to a u32 to function as a
> > > "replace set." A newly loaded livepatch will now atomically replace any
> > > existing patch belonging to the same set. There can only ever be one active
> > > livepatch for a given replace_set number.
> > >
> > > This change currently supports function replacement only. Livepatches that
> > > belong to different replace sets cannot modify the same function. If a new
> > > livepatch attempts to modify a function already modified by an older
> > > livepatch from a different replace_set, the loading of the new livepatch
> > > will be refused.
> > >
> > > Similarly, for the KLP state, livepatches belonging to different replace
> > > sets cannot use the same state ID. The system will refuse to load a new
> > > livepatch if it uses a state ID already in use by an older livepatch from
> > > a different replace_set.
> > >
> > > For the KLP shadow variable mechanism, developers must assign unique shadow
> > > IDs to livepatches that belong to different replace sets.
> > >
> > > Support for replace_set compatibility with KLP state and shadow variables
> > > will be implemented after Petr's KLP state transfer work is completed [0].
> > >
> > > Other user-visible changes include:
> > > - The non-replace model is now deprecated
> > > - /sys/kernel/livepatch/livepatch_XXX/replace attribute is replaced by
> > >   /sys/kernel/livepatch/livepatch_XXX/replace_set

> > New idea:
> >
> > I have briefly discussed the new semantic with Miroslav when I met
> > him in person. And he was a bit concerned. We as an OS distributor
> > might want to be sure that our livepatches can be installed the most
> > safe way. So, we still might want to preserve the "replace all"
> > semantic to make sure that our livepatches will not break anything.
> >
> > I though about 4 approaches approaches:
> >
> > 1. Make .replace_set=0 special so that it will always replace
> >    everything. Similar to the current .replace=true mode.
> >
> >    Customers will still be able to install custom livepatches
> >    later with .replace_set != 0. But the "0" livepatch will
> >    always wipe them out.
> >
> >
> > 2. Use two flags in the livepatch, for example
> >
> >      a. Rename .replace to .replace_all. The livepatch with this
> >         flag set will always wipe all other livepatches.
> >
> >      b. Add .replace_set which will allow to install more livepatches
> >         in parallel, replace the livepatches with the same .replace_set
> >         atomically, and check the compatibility. As described above.
> >
> >     It is a bit more complicated. But it is more compatible with
> >     the current state. And it removes the special meaning of
> >     .replace_set == 0.
> >
> >
> > 3. Introduce a system wide flag, sysctl livepatch_replace_all
> >    which would allow to enable/disable the replace_all feature
> >    of either .replace_set == 0 or per-patch.replace_all flag.
> >
> >    It would allow the customer to preserve their custom livepatches
> >    when they know what they do. For example, when they use the livepatch
> >    to modify a 3rd party module or tune some functionality.
> >
> >
> > 4. Just taint the kernel when a livepatch with .replace_set != 0
> >    is installed. Then the OS provider could say that a tainted kernel
> >    is not longer officially supported.
> 
> Since the kernel is already tainted with TAINT_LIVEPATCH upon loading
> a livepatch, are you recommending the addition of a distinct flag,
> such as TAINT_LIVEPATCH_REPLACE_SET?

Yeah, I would call it TAINT_PARALLEL_LIVEPATCH or
TAINT_MORE_LIVEPATCHES.

But maybe, it is not necessary. We have a tool which allows to get
info about the running system, including the loaded modules and
livepatches. It might be enough.

Let's see what others think about this. Note that Miroslav has
vacation this week.

Best Regards,
Petr

  reply	other threads:[~2026-06-10  9:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-07 13:16 [PATCH v3 0/7] livepatch: Introduce replace set support Yafang Shao
2026-06-07 13:16 ` [PATCH v3 1/7] livepatch: Fix NULL pointer dereference in klp_find_func() Yafang Shao
2026-06-09 13:27   ` Petr Mladek
2026-06-10  3:00     ` Yafang Shao
2026-06-07 13:16 ` [PATCH v3 2/7] livepatch: Move klp_find_func() into core.h Yafang Shao
2026-06-09 15:28   ` Petr Mladek
2026-06-10  3:01     ` Yafang Shao
2026-06-07 13:16 ` [PATCH v3 3/7] livepatch: Support scoped atomic replace using replace_set Yafang Shao
2026-06-07 13:33   ` sashiko-bot
2026-06-07 14:00     ` Yafang Shao
2026-06-09 16:00   ` Petr Mladek
2026-06-10  3:24     ` Yafang Shao
2026-06-10  9:48       ` Petr Mladek [this message]
2026-06-07 13:16 ` [PATCH v3 4/7] livepatch: Deprecate stack_order Yafang Shao
2026-06-07 13:31   ` sashiko-bot
2026-06-07 13:16 ` [PATCH v3 5/7] selftests/livepatch: Update tests for replace_set Yafang Shao
2026-06-07 13:29   ` sashiko-bot
2026-06-07 13:16 ` [PATCH v3 6/7] selftests/livepatch: Add test for state ID conflict across replace_sets Yafang Shao
2026-06-07 13:16 ` [PATCH v3 7/7] selftests/livepatch: Add test for function " Yafang Shao

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=aiky7hr6sFMjXD-P@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=laoar.shao@gmail.com \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=song@kernel.org \
    /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