mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miroslav Benes <mbenes@suse.cz>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Petr Mladek <pmladek@suse.com>, Jiri Kosina <jikos@kernel.org>,
	Joe Lawrence <joe.lawrence@redhat.com>,
	Jessica Yu <jeyu@kernel.org>, Nicolai Stange <nstange@suse.de>,
	live-patching@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] livepatch: Allow to unregister or free shadow data using a custom function
Date: Wed, 21 Mar 2018 14:05:14 +0100 (CET)	[thread overview]
Message-ID: <alpine.LSU.2.21.1803211404010.19993@pobox.suse.cz> (raw)
In-Reply-To: <20180314193217.jl2pkzikzrk7wgpz@treble>

On Wed, 14 Mar 2018, Josh Poimboeuf wrote:

> On Tue, Mar 13, 2018 at 04:54:48PM +0100, Petr Mladek wrote:
> > We might need to do some actions before the shadow variable is freed.
> > For example, we might need to remove it from a list or free some data
> > that it points to.
> > 
> > This is already possible now. The user can get the shadow variable
> > by klp_shadow_get(), do the necessary actions, and then call
> > klp_shadow_free().
> > 
> > This patch allow to do this a more elegant way. The user could implement
> > the needed actions in a callback that is passed to klp_shadow_free()
> > as a parameter. The callback usually does reverse operations to
> > the init_func that can be called by klp_shadow_*alloc().
> > 
> > It is especially useful for klp_shadow_free_all(). There we need to do
> > these extra actions for each found shadow variable with the given ID.
> > 
> > Note that the memory used by the shadow variable itself is still released
> > later by rcu callback. It is needed to protect internal structures that
> > keep all shadow variables. But free_func is called immediately. The shadow
> > variable must not be access anyway after klp_shadow_free() is called.
> > The user is responsible to protect this any suitable way.
> > 
> > Be aware that free_func callback is called under klp_shadow_lock. It is
> > the same as for init_func in klp_shadow_alloc().
> > 
> > Signed-off-by: Petr Mladek <pmladek@suse.com>
> 
> Makes sense, though I'm not sure "free" is the right name:
> 
>   a) "free" isn't the opposite of "init"; and
> 
>   b) it may be used for things other than freeing.
>   
> Shall we call them constructor/destructor?

Agreed. _ctor/_dtor both sound better.

Miroslav

      reply	other threads:[~2018-03-21 13:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-13 15:54 [PATCH 0/2] livepatch: Allocate and free shadow variables more safely Petr Mladek
2018-03-13 15:54 ` [PATCH 1/2] livepatch: Initialize shadow variables by init function safely Petr Mladek
2018-03-14 19:27   ` Joe Lawrence
2018-03-14 19:44     ` Josh Poimboeuf
2018-04-04 13:08       ` Petr Mladek
2018-03-14 19:28   ` Josh Poimboeuf
2018-03-14 19:43     ` Joe Lawrence
2018-03-14 20:22       ` Josh Poimboeuf
2018-03-21 12:55   ` Miroslav Benes
2018-03-13 15:54 ` [PATCH 2/2] livepatch: Allow to unregister or free shadow data using a custom function Petr Mladek
2018-03-14 19:32   ` Josh Poimboeuf
2018-03-21 13:05     ` Miroslav Benes [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=alpine.LSU.2.21.1803211404010.19993@pobox.suse.cz \
    --to=mbenes@suse.cz \
    --cc=jeyu@kernel.org \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=nstange@suse.de \
    --cc=pmladek@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

all inboxes | Powered by JetHome®