live-patching.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Miroslav Benes <mbenes@suse.cz>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
	Joe Lawrence <joe.lawrence@redhat.com>,
	Nicolai Stange <nstange@suse.de>,
	live-patching@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [POC 2/7] livepatch: Allow to handle lifetime of shadow variables using the livepatch state
Date: Thu, 15 Aug 2024 15:43:37 +0200	[thread overview]
Message-ID: <Zr4GCYkfof1aJ-hp@pathway.suse.cz> (raw)
In-Reply-To: <alpine.LSU.2.21.2407251329300.21729@pobox.suse.cz>

On Thu 2024-07-25 13:31:40, Miroslav Benes wrote:
> > diff --git a/kernel/livepatch/state.c b/kernel/livepatch/state.c
> > index 6693d808106b..4ec65afe3a43 100644
> > --- a/kernel/livepatch/state.c
> > +++ b/kernel/livepatch/state.c
> > @@ -198,11 +198,17 @@ void klp_release_states(struct klp_patch *patch)
> >  		if (is_state_in_other_patches(patch, state))
> >  			continue;
> >  
> > -		if (!state->callbacks.release)
> > -			continue;
> > -
> > -		if (state->callbacks.setup_succeeded)
> > +		if (state->callbacks.release && state->callbacks.setup_succeeded)
> >  			state->callbacks.release(patch, state);
> > +
> > +		if (state->is_shadow)
> > +			klp_shadow_free_all(state->id, state->callbacks.shadow_dtor);
> 
> The following
> 
> > +		/*
> > +		 * The @release callback is supposed to restore the original
> > +		 * state before the @setup callback was called.
> > +		 */
> > +		state->callbacks.setup_succeeded = 0;
> 
> should go to the previous patch perhaps?

Great catch!

I am going to refactor the code in the next version so that it would
look like:

void klp_states_post_unpatch(struct klp_patch *patch)
{
	struct klp_state *state;

	klp_for_each_state(patch, state) {
		if (is_state_in_other_patches(patch, state))
			continue;

		if (!state->callbacks.pre_patch_succeeded)
			continue;

		if (state->callbacks.post_unpatch)
			state->callbacks.post_unpatch(patch, state);

+		if (state->is_shadow)
+			klp_shadow_free_all(state->id, state->callbacks.shadow_dtor);
+
		state->callbacks.pre_patch_succeeded = 0;
	}
}


Best Regards,
Petr


  reply	other threads:[~2024-08-15 13:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-10 17:04 [POC 0/7] livepatch: Make livepatch states, callbacks, and shadow variables work together Petr Mladek
2023-11-10 17:04 ` [POC 1/7] livepatch: Add callbacks for introducing and removing states Petr Mladek
2023-11-11  0:54   ` kernel test robot
2023-11-11  3:19   ` kernel test robot
2023-11-10 17:04 ` [POC 2/7] livepatch: Allow to handle lifetime of shadow variables using the livepatch state Petr Mladek
2024-07-25 11:31   ` Miroslav Benes
2024-08-15 13:43     ` Petr Mladek [this message]
2023-11-10 17:04 ` [POC 3/7] livepatch: Use per-state callbacks in state API tests Petr Mladek
2024-07-25 11:48   ` Miroslav Benes
2024-08-16 16:02     ` Petr Mladek
2023-11-10 17:04 ` [POC 4/7] livepatch: Do not use callbacks when testing sysfs interface Petr Mladek
2023-11-10 17:04 ` [POC 5/7] livepatch: Convert klp module callbacks tests into livepatch module tests Petr Mladek
2023-11-11  1:15   ` kernel test robot
2024-07-25 12:22   ` Miroslav Benes
2023-11-10 17:04 ` [POC 6/7] livepatch: Remove the obsolete per-object callbacks Petr Mladek
2023-11-10 17:04 ` [POC 7/7] livepatching: Remove per-state version Petr Mladek
2024-07-25 14:16   ` Miroslav Benes
2024-08-15 14:00     ` Petr Mladek
2023-11-10 21:33 ` [POC 0/7] livepatch: Make livepatch states, callbacks, and shadow variables work together Josh Poimboeuf
2024-07-25 14:19   ` Miroslav Benes
2024-08-15 10:08     ` Petr Mladek
2024-07-25 14:22 ` Miroslav Benes
2024-07-25 14:40   ` Nicolai Stange
     [not found]   ` <66a263d5.170a0220.b2c84.1870SMTPIN_ADDED_BROKEN@mx.google.com>
2024-08-21 15:28     ` Petr Mladek

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=Zr4GCYkfof1aJ-hp@pathway.suse.cz \
    --to=pmladek@suse.com \
    --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=nstange@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).