From: Petr Mladek <pmladek@suse.com>
To: Jiri Kosina <jikos@kernel.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Miroslav Benes <mbenes@suse.cz>
Cc: Jason Baron <jbaron@akamai.com>,
Joe Lawrence <joe.lawrence@redhat.com>,
Jessica Yu <jeyu@kernel.org>,
Evgenii Shatokhin <eshatokhin@virtuozzo.com>,
live-patching@vger.kernel.org, linux-kernel@vger.kernel.org,
Petr Mladek <pmladek@suse.com>
Subject: [PATCH 7/8] livepatch: Allow to replace even disabled patches
Date: Fri, 23 Mar 2018 13:00:27 +0100 [thread overview]
Message-ID: <20180323120028.31451-8-pmladek@suse.com> (raw)
In-Reply-To: <20180323120028.31451-1-pmladek@suse.com>
Patches without the replace flag might depend on each other. It makes
sense to enforce the order in which they are enabled and disabled.
The situation is different when the patch replaces all existing ones.
These patches should make the life easier for both: patch producers
and users. Such a patch should be ready to replace basically any
older patch. It should work well even in situations when the previous
patches were not installed or when they were disabled from some reasons.
The code is almost ready for this. There are needed two changes:
+ Disable only enabled patches in klp_discard_replaced_patches().
+ Stop enforcing the stack order for the patches with the replace flag.
Instead, we need to make sure that they are still usable (not
replaced). This check is already there.
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
kernel/livepatch/core.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 0b3be6e14b80..c64371ffc063 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -355,11 +355,13 @@ void klp_discard_replaced_patches(struct klp_patch *new_patch, bool keep_module)
if (old_patch == new_patch)
return;
- klp_unpatch_objects(old_patch);
- old_patch->enabled = false;
+ if (old_patch->enabled) {
+ klp_unpatch_objects(old_patch);
+ old_patch->enabled = false;
- if (!keep_module)
- module_put(old_patch->mod);
+ if (!keep_module)
+ module_put(old_patch->mod);
+ }
/*
* Replaced patches could not get re-enabled to keep
@@ -453,8 +455,13 @@ static int __klp_enable_patch(struct klp_patch *patch)
if (!klp_is_patch_on_stack(patch))
return -EINVAL;
- /* Only the first disabled patch can be enabled. */
- if (patch->list.prev != &klp_patches &&
+ /*
+ * Only the first disabled patch can be enabled. This is not required
+ * for patches with the replace flags. They override even disabled
+ * patches that were registered earlier.
+ */
+ if (!patch->replace &&
+ patch->list.prev != &klp_patches &&
!list_prev_entry(patch, list)->enabled)
return -EBUSY;
--
2.13.6
next prev parent reply other threads:[~2018-03-23 12:01 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-23 12:00 [PATCH 0/8] livepatch: Atomic replace feature Petr Mladek
2018-03-23 12:00 ` [PATCH 1/8] livepatch: Use lists to manage patches, objects and functions Petr Mladek
2018-03-23 12:00 ` [PATCH 2/8] livepatch: Free only structures with initialized kobject Petr Mladek
2018-03-23 12:00 ` [PATCH 3/8] livepatch: Add atomic replace Petr Mladek
2018-04-06 22:05 ` Josh Poimboeuf
2018-04-09 13:53 ` Miroslav Benes
2018-04-10 9:31 ` Petr Mladek
2018-03-23 12:00 ` [PATCH 4/8] livepatch: Add an extra flag to distinguish registered patches Petr Mladek
2018-04-06 22:06 ` Josh Poimboeuf
2018-04-09 14:02 ` Miroslav Benes
2018-04-10 10:56 ` Petr Mladek
2018-04-10 17:53 ` Josh Poimboeuf
2018-03-23 12:00 ` [PATCH 5/8] livepatch: Remove replaced patches from the stack Petr Mladek
2018-03-23 12:00 ` [PATCH 6/8] livepatch: Remove Nop structures when unused Petr Mladek
2018-04-06 22:07 ` Josh Poimboeuf
2018-04-10 9:14 ` Miroslav Benes
2018-04-10 11:09 ` Petr Mladek
2018-03-23 12:00 ` Petr Mladek [this message]
2018-03-23 12:00 ` [PATCH 8/8] livepatch: Atomic replace and cumulative patches documentation Petr Mladek
2018-03-23 14:54 ` [PATCH 0/8] livepatch: Atomic replace feature Petr Mladek
2018-04-06 22:10 ` Josh Poimboeuf
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=20180323120028.31451-8-pmladek@suse.com \
--to=pmladek@suse.com \
--cc=eshatokhin@virtuozzo.com \
--cc=jbaron@akamai.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 \
/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