mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] livepatch: Allocate and free shadow variables more safely
@ 2018-04-05 12:23 Petr Mladek
  2018-04-05 12:23 ` [PATCH v2 1/2] livepatch: Initialize shadow variables safely by a custom callback Petr Mladek
  2018-04-05 12:23 ` [PATCH v2 2/2] livepatch: Allow to call a custom callback when freeing shadow variables Petr Mladek
  0 siblings, 2 replies; 6+ messages in thread
From: Petr Mladek @ 2018-04-05 12:23 UTC (permalink / raw)
  To: Jiri Kosina, Josh Poimboeuf, Miroslav Benes
  Cc: Joe Lawrence, Jessica Yu, Nicolai Stange, live-patching,
	linux-kernel, Petr Mladek

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


Petr Mladek (2):
  livepatch: Initialize shadow variables safely by a custom callback
  livepatch: Allow to call a custom callback when freeing shadow
    variables

 Documentation/livepatch/shadow-vars.txt   |  41 +++++++----
 include/linux/livepatch.h                 |  19 ++++--
 kernel/livepatch/shadow.c                 | 109 ++++++++++++++++++++----------
 samples/livepatch/livepatch-shadow-fix1.c |  43 +++++++++---
 samples/livepatch/livepatch-shadow-fix2.c |  33 +++++----
 5 files changed, 164 insertions(+), 81 deletions(-)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-04-11  9:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-05 12:23 [PATCH v2 0/2] livepatch: Allocate and free shadow variables more safely Petr Mladek
2018-04-05 12:23 ` [PATCH v2 1/2] livepatch: Initialize shadow variables safely by a custom callback Petr Mladek
2018-04-06 22:34   ` Josh Poimboeuf
2018-04-10 11:33     ` Petr Mladek
2018-04-11  9:29   ` Miroslav Benes
2018-04-05 12:23 ` [PATCH v2 2/2] livepatch: Allow to call a custom callback when freeing shadow variables Petr Mladek

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®