Live Patching
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Song Liu <song@kernel.org>
Cc: Harry Hsu <x90613@gmail.com>,
	jpoimboe@kernel.org, mbenes@suse.cz, joe.lawrence@redhat.com,
	jikos@kernel.org, live-patching@vger.kernel.org,
	linux-kernel@vger.kernel.org, sashiko-bot@kernel.org
Subject: Re: [PATCH 2/2] livepatch: Clean up klp_init_object_loaded() when fails
Date: Mon, 31 Aug 2026 10:44:09 +0200	[thread overview]
Message-ID: <apU-2f7rffaTUKWC@pathway.suse.cz> (raw)
In-Reply-To: <CAPhsuW7Jr16Wyd4oEXKEwJPwX=p7HWLZTA63uNeu=13GYf+=Uw@mail.gmail.com>

On Fri 2026-08-28 10:44:38, Song Liu wrote:
> On Fri, Aug 28, 2026 at 5:53 AM Petr Mladek <pmladek@suse.com> wrote:
> >
> > When a module is loaded, klp_module_coming() iterates over patches and
> > calls klp_init_object_loaded(). If initialization fails, it delegates
> > cleanup to klp_cleanup_module_patches_limited().
> >
> > However, the cleanup loop skips the failing patch. Each function called
> > in klp_init_object_loaded() is supposed to clean its own changes. This
> > works except for the changes done by klp_init_object_loaded().
> >
> > The current code is a bit messy. The changes done by
> > klp_init_object_loaded() should get cleared by klp_free_object_loaded().
> > But this function also clears obj->mod which is set by
> > klp_module_coming(). And relocations are cleared separately.
> >
> > Fix the situations by updating klp_free_object_loaded(). It should
> > revert all and only changes made by klp_init_object_loaded().
> > This requires some shuffling:
> >
> >  + Clear obj->mod explicitly in klp_cleanup_module_patches_limited()
> >    and do not rely on klp_free_object_loaded().
> >
> >  + Clear relocations in klp_free_object_loaded(). Remove the explicit
> >    call from klp_cleanup_module_patches_limited(). This requires
> >    adding the @patch parameter.
> >
> > Finally, call klp_free_object_loaded() in the error path in
> > klp_init_object_loaded().
> >
> > Reported-by: sashiko-bot@kernel.org
> > Closes: https://lore.kernel.org/r/20260823062313.1321B1F000E9@smtp.kernel.org
> > Signed-off-by: Petr Mladek <pmladek@suse.com>
> 
> Acked-by: Song Liu <song@kernel.org>
> 
> With one nitpick

> > --- a/kernel/livepatch/core.c
> > +++ b/kernel/livepatch/core.c
> > @@ -725,18 +725,20 @@ static void __klp_free_funcs(struct klp_object *obj, bool nops_only)
> >  }
> >
> >  /* Clean up when a patched object is unloaded */
> > -static void klp_free_object_loaded(struct klp_object *obj)
> > +static void klp_free_object_loaded(struct klp_patch *patch, struct klp_object *obj)
> 
> nit: Do we still need to fit every line in 80 characters? checkpatch.pl
> only enforce 100 characters these days.

I do not have strong opinion about it. My editor highlights characters
which are over the 80 lines limit so I automatically fix it. I haven't
found a courage to change it yet. And my eyes are getting worse over
the years so I use big fonts. 80 characters per line look good
on my monitor ;-)

Best Regards,
Petr

  reply	other threads:[~2026-08-31  8:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-23  6:07 [PATCH v2] livepatch: Reject livepatches with aliased old_func Harry Hsu
2026-08-23  6:23 ` sashiko-bot
2026-08-27 15:45   ` Petr Mladek
2026-08-28 12:52     ` [PATCH 0/2] livepatch: Clear relocations when klp_init_object_loaded() fails Petr Mladek
2026-08-28 12:52       ` [PATCH 1/2] livepatch: Move code for updating livepatch object relocations Petr Mladek
2026-08-28 17:02         ` Song Liu
2026-08-28 17:41           ` Josh Poimboeuf
2026-08-28 17:52             ` Song Liu
2026-08-28 12:52       ` [PATCH 2/2] livepatch: Clean up klp_init_object_loaded() when fails Petr Mladek
2026-08-28 17:44         ` Song Liu
2026-08-31  8:44           ` Petr Mladek [this message]
2026-08-27 14:42 ` [PATCH v2] livepatch: Reject livepatches with aliased old_func Petr Mladek
2026-08-27 22:57 ` Josh Poimboeuf
2026-08-28  9:25 ` Miroslav Benes
2026-08-28 16:17 ` Song Liu
2026-08-30 17:51   ` Harry Hsu
2026-08-30 17:51   ` Harry Hsu

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=apU-2f7rffaTUKWC@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=sashiko-bot@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