mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Jiri Kosina <jikos@kernel.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Miroslav Benes <mbenes@suse.cz>
Cc: 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,
	Petr Mladek <pmladek@suse.com>
Subject: [PATCH 0/2] livepatch: Allocate and free shadow variables more safely
Date: Tue, 13 Mar 2018 16:54:46 +0100	[thread overview]
Message-ID: <20180313155448.1998-1-pmladek@suse.com> (raw)

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


The patchset is against the current Linus' tree.

Petr Mladek (2):
  livepatch: Initialize shadow variables by init function safely
  livepatch: Allow to unregister or free shadow data using a custom
    function

 Documentation/livepatch/shadow-vars.txt   | 42 ++++++++++++-----
 include/linux/livepatch.h                 | 23 +++++++---
 kernel/livepatch/shadow.c                 | 75 +++++++++++++++++++++----------
 samples/livepatch/livepatch-shadow-fix1.c | 44 +++++++++++++-----
 samples/livepatch/livepatch-shadow-fix2.c | 33 +++++++-------
 5 files changed, 150 insertions(+), 67 deletions(-)

-- 
2.13.6

             reply	other threads:[~2018-03-13 15:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-13 15:54 Petr Mladek [this message]
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

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=20180313155448.1998-1-pmladek@suse.com \
    --to=pmladek@suse.com \
    --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=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

Powered by JetHome