From: Petr Mladek <pmladek@suse.com>
To: Joe Lawrence <joe.lawrence@redhat.com>
Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org,
Josh Poimboeuf <jpoimboe@redhat.com>,
Jessica Yu <jeyu@kernel.org>, Jiri Kosina <jikos@kernel.org>,
Miroslav Benes <mbenes@suse.cz>,
Chris J Arges <chris.j.arges@canonical.com>
Subject: Re: [PATCH v5 1/3] livepatch: add (un)patch callbacks
Date: Tue, 26 Sep 2017 16:49:12 +0200 [thread overview]
Message-ID: <20170926144912.GH21048@pathway.suse.cz> (raw)
In-Reply-To: <1504191233-2642-2-git-send-email-joe.lawrence@redhat.com>
On Thu 2017-08-31 10:53:51, Joe Lawrence wrote:
> diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> index b9628e43c78f..aca62c4b8616 100644
> --- a/kernel/livepatch/core.c
> +++ b/kernel/livepatch/core.c
> @@ -54,11 +54,6 @@ static bool klp_is_module(struct klp_object *obj)
> return obj->name;
> }
>
> -static bool klp_is_object_loaded(struct klp_object *obj)
> -{
> - return !obj->name || obj->mod;
> -}
> -
> /* sets obj->mod if object is not vmlinux and module is found */
> static void klp_find_object_module(struct klp_object *obj)
> {
> @@ -285,6 +280,8 @@ static int klp_write_object_relocations(struct module *pmod,
>
> static int __klp_disable_patch(struct klp_patch *patch)
> {
> + struct klp_object *obj;
> +
> if (klp_transition_patch)
> return -EBUSY;
>
> @@ -295,6 +292,10 @@ static int __klp_disable_patch(struct klp_patch *patch)
>
> klp_init_transition(patch, KLP_UNPATCHED);
>
> + klp_for_each_object(patch, obj)
> + if (patch->enabled && obj->patched)
> + klp_pre_unpatch_callback(obj);
> +
> /*
> * Enforce the order of the func->transition writes in
> * klp_init_transition() and the TIF_PATCH_PENDING writes in
> @@ -388,13 +389,18 @@ static int __klp_enable_patch(struct klp_patch *patch)
> if (!klp_is_object_loaded(obj))
> continue;
>
> - ret = klp_patch_object(obj);
> + ret = klp_pre_patch_callback(obj);
> if (ret) {
> - pr_warn("failed to enable patch '%s'\n",
> - patch->mod->name);
> + pr_warn("pre-patch callback failed for object '%s'\n",
> + klp_is_module(obj) ? obj->name : "vmlinux");
> + goto err;
> + }
>
> - klp_cancel_transition();
> - return ret;
> + ret = klp_patch_object(obj);
> + if (ret) {
> + pr_warn("failed to patch object '%s'\n",
> + klp_is_module(obj) ? obj->name : "vmlinux");
We should call klp_post_unpatch_callback(obj) here to make it
synchronous.
Well, what about calling:
klp_pre_patch_callback() inside klp_patch_object() and
klp_post_unpatch_callback() inside klp_unpatch_object()
By other words, we would do the two operations. It would have
two advantages:
+ error handling for free
+ no need for the strange callbacks_enabled flag
It would require the more strict consistency model if there
is a dependency between the callbacks and patches from various
modules. But we would probably need the consistency model
in this case anyway.
> + goto err;
> }
> }
>
Otherwise I think that we are getting close.
Best Regards,
Petr
PS: I hope that the above problem and solution has not been mentioned
yet. I am sorry if it was. I am a bit lost in many mails after
vacation, sickness, and conference.
next prev parent reply other threads:[~2017-09-26 14:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-31 14:53 [PATCH v5 0/3] livepatch callbacks Joe Lawrence
2017-08-31 14:53 ` [PATCH v5 1/3] livepatch: add (un)patch callbacks Joe Lawrence
2017-09-12 8:53 ` Miroslav Benes
2017-09-12 15:48 ` Joe Lawrence
2017-09-12 22:05 ` Joe Lawrence
2017-09-12 22:22 ` Josh Poimboeuf
2017-09-13 7:29 ` Miroslav Benes
2017-09-13 13:53 ` Joe Lawrence
2017-09-13 21:36 ` [RFC] livepatch: unpatch all klp_objects if klp_module_coming fails Joe Lawrence
2017-09-20 11:19 ` Miroslav Benes
2017-09-20 15:17 ` Joe Lawrence
2017-09-27 12:17 ` Petr Mladek
2017-09-13 7:22 ` [PATCH v5 1/3] livepatch: add (un)patch callbacks Miroslav Benes
2017-09-26 14:49 ` Petr Mladek [this message]
2017-09-26 19:01 ` Joe Lawrence
2017-09-27 8:02 ` Petr Mladek
2017-08-31 14:53 ` [PATCH v5 2/3] livepatch: move transition "complete" notice into klp_complete_transition() Joe Lawrence
2017-09-12 9:09 ` Miroslav Benes
2017-09-27 11:35 ` Petr Mladek
2017-08-31 14:53 ` [PATCH v5 3/3] livepatch: add transition notices Joe Lawrence
2017-09-12 9:29 ` Miroslav Benes
2017-09-27 11:49 ` Petr Mladek
2017-09-27 15:45 ` Joe Lawrence
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=20170926144912.GH21048@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=chris.j.arges@canonical.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