Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

livepatch: Module coming and going callbacks can proceed with all listed patches

Livepatches can no longer get enabled and disabled repeatedly.
The list klp_patches contains only enabled patches and eventually
the patch in transition.

The module coming and going callbacks do no longer need to check
for these state. They have to proceed with all listed patches.

Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>

+6 -20
+6 -20
kernel/livepatch/core.c
··· 1141 1141 if (!klp_is_module(obj) || strcmp(obj->name, mod->name)) 1142 1142 continue; 1143 1143 1144 - /* 1145 - * Only unpatch the module if the patch is enabled or 1146 - * is in transition. 1147 - */ 1148 - if (patch->enabled || patch == klp_transition_patch) { 1144 + if (patch != klp_transition_patch) 1145 + klp_pre_unpatch_callback(obj); 1149 1146 1150 - if (patch != klp_transition_patch) 1151 - klp_pre_unpatch_callback(obj); 1147 + pr_notice("reverting patch '%s' on unloading module '%s'\n", 1148 + patch->mod->name, obj->mod->name); 1149 + klp_unpatch_object(obj); 1152 1150 1153 - pr_notice("reverting patch '%s' on unloading module '%s'\n", 1154 - patch->mod->name, obj->mod->name); 1155 - klp_unpatch_object(obj); 1156 - 1157 - klp_post_unpatch_callback(obj); 1158 - } 1151 + klp_post_unpatch_callback(obj); 1159 1152 1160 1153 klp_free_object_loaded(obj); 1161 1154 break; ··· 1186 1193 patch->mod->name, obj->mod->name, ret); 1187 1194 goto err; 1188 1195 } 1189 - 1190 - /* 1191 - * Only patch the module if the patch is enabled or is 1192 - * in transition. 1193 - */ 1194 - if (!patch->enabled && patch != klp_transition_patch) 1195 - break; 1196 1196 1197 1197 pr_notice("applying patch '%s' to loading module '%s'\n", 1198 1198 patch->mod->name, obj->mod->name);