LKML Archive on
help / color / mirror / Atom feed
From: Josh Poimboeuf <>
To: Petr Mladek <>
Cc: Jiri Kosina <>, Miroslav Benes <>,
	Joe Lawrence <>,
	Jessica Yu <>, Nicolai Stange <>,,
Subject: Re: [PATCH v3 0/2] livepatch: Allocate and free shadow variables more safely
Date: Mon, 16 Apr 2018 14:57:42 -0500	[thread overview]
Message-ID: <20180416195742.n2zsthypbx7c4yzn@treble> (raw)
In-Reply-To: <>

On Mon, Apr 16, 2018 at 01:36:45PM +0200, Petr Mladek wrote:
> Nikolai started to use shadow variables and found that list_head
> is not initialized correctly using the existing API.
> The problem is that LIST_HEAD_INIT() set pointers to itself.
> klp_shadow_alloc() then copies these pointers to another location.
> It would be possible to solve this by a late initialization. But
> this does not work well with klp_shadow_get_or_alloc(). Also this
> behavior is error prone. Note that list_head might be hidden in
> another structure, for example mutex.
> I suggest to change the API and allow to initialize the shadow
> variables using a custom callback. I think that we have already
> talked about this but we decided to go the easier way. It seems
> that it was a bad decision.
> I send also patch that add a symmetric callback to the klp_shadow_free()
> functions. It might be handy especially for klp_shadow_free_all().
> Changes against v2:
>   + Use pr_err() instead of WARN() when ctor() fails [Josh]
>   + Some typos [Mirek]
> Changes against v1:
>   + Rename init/free callbacks to ctor/dtor
>   + Misc update of comments and commit messages
>   + Fix sizeof() in the sample code in shadow-vars.txt

Acked-by: Josh Poimboeuf <>


  parent reply	other threads:[~2018-04-16 19:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 11:36 Petr Mladek
2018-04-16 11:36 ` [PATCH v3 1/2] livepatch: Initialize shadow variables safely by a custom callback Petr Mladek
2018-04-16 11:36 ` [PATCH v3 2/2] livepatch: Allow to call a custom callback when freeing shadow variables Petr Mladek
2018-04-16 19:57 ` Josh Poimboeuf [this message]
2018-04-17 11:21 ` [PATCH v3 0/2] livepatch: Allocate and free shadow variables more safely Miroslav Benes
2018-04-17 11:44 ` Jiri Kosina

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180416195742.n2zsthypbx7c4yzn@treble \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH v3 0/2] livepatch: Allocate and free shadow variables more safely' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).