Re: [PATCH 6/8] livepatch: Remove Nop structures when unused

From: Josh Poimboeuf
Date: Fri Apr 06 2018 - 18:07:32 EST


On Fri, Mar 23, 2018 at 01:00:26PM +0100, Petr Mladek wrote:
> Replaced patches are removed from the stack when the transition is
> finished. It means that Nop structures will never be needed again
> and can be removed. Why should we care?

Warning, grammar pedantry ahead.

"Nop" isn't a proper noun, so it shouldn't be capitalized (here and in
the patch subject).

Also, "NOP", used elsewhere, might be confused with x86 NOP
instructions. I would vote for "nop" everywhere.

> @@ -146,6 +155,21 @@ static void klp_complete_transition(void)
> if (!klp_forced && klp_target_state == KLP_UNPATCHED)
> module_put(klp_transition_patch->mod);
>
> + if (klp_transition_patch->replace && klp_target_state == KLP_PATCHED) {
> + /*
> + * We do not need to wait until the objects are really freed.
> + * We will never need them again because the patch must be on
> + * the bottom of the stack now.
> + */
> + klp_free_objects_dynamic(klp_transition_patch);
> + /*
> + * Replace behavior will not longer be needed. Avoid the related
> + * code when disabling and enabling again.

"not longer" -> "no longer"

--
Josh