Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/livepatching
Pull livepatching updates from Jiri Kosina: - fix for patching modules that contain .altinstructions or .parainstructions sections, from Jessica Yu - make TAINT_LIVEPATCH a per-module flag (so that it's immediately clear which module caused the taint), from Josh Poimboeuf * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/livepatching: livepatch/module: make TAINT_LIVEPATCH module-specific Documentation: livepatch: add section about arch-specific code livepatch/x86: apply alternatives and paravirt patches after relocations livepatch: use arch_klp_init_object_loaded() to finish arch-specific tasks
This commit is contained in:
@@ -274,7 +274,6 @@ static int klp_write_object_relocations(struct module *pmod,
|
||||
|
||||
objname = klp_is_module(obj) ? obj->name : "vmlinux";
|
||||
|
||||
module_disable_ro(pmod);
|
||||
/* For each klp relocation section */
|
||||
for (i = 1; i < pmod->klp_info->hdr.e_shnum; i++) {
|
||||
sec = pmod->klp_info->sechdrs + i;
|
||||
@@ -309,7 +308,6 @@ static int klp_write_object_relocations(struct module *pmod,
|
||||
break;
|
||||
}
|
||||
|
||||
module_enable_ro(pmod, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -547,9 +545,6 @@ static int __klp_enable_patch(struct klp_patch *patch)
|
||||
list_prev_entry(patch, list)->state == KLP_DISABLED)
|
||||
return -EBUSY;
|
||||
|
||||
pr_notice_once("tainting kernel with TAINT_LIVEPATCH\n");
|
||||
add_taint(TAINT_LIVEPATCH, LOCKDEP_STILL_OK);
|
||||
|
||||
pr_notice("enabling patch '%s'\n", patch->mod->name);
|
||||
|
||||
klp_for_each_object(patch, obj) {
|
||||
@@ -763,6 +758,12 @@ static int klp_init_func(struct klp_object *obj, struct klp_func *func)
|
||||
func->old_sympos ? func->old_sympos : 1);
|
||||
}
|
||||
|
||||
/* Arches may override this to finish any remaining arch-specific tasks */
|
||||
void __weak arch_klp_init_object_loaded(struct klp_patch *patch,
|
||||
struct klp_object *obj)
|
||||
{
|
||||
}
|
||||
|
||||
/* parts of the initialization that is done only when the object is loaded */
|
||||
static int klp_init_object_loaded(struct klp_patch *patch,
|
||||
struct klp_object *obj)
|
||||
@@ -770,9 +771,15 @@ static int klp_init_object_loaded(struct klp_patch *patch,
|
||||
struct klp_func *func;
|
||||
int ret;
|
||||
|
||||
module_disable_ro(patch->mod);
|
||||
ret = klp_write_object_relocations(patch->mod, obj);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
module_enable_ro(patch->mod, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
arch_klp_init_object_loaded(patch, obj);
|
||||
module_enable_ro(patch->mod, true);
|
||||
|
||||
klp_for_each_func(obj, func) {
|
||||
ret = klp_find_object_symbol(obj->name, func->old_name,
|
||||
|
||||
@@ -1149,6 +1149,8 @@ static size_t module_flags_taint(struct module *mod, char *buf)
|
||||
buf[l++] = 'C';
|
||||
if (mod->taints & (1 << TAINT_UNSIGNED_MODULE))
|
||||
buf[l++] = 'E';
|
||||
if (mod->taints & (1 << TAINT_LIVEPATCH))
|
||||
buf[l++] = 'K';
|
||||
/*
|
||||
* TAINT_FORCED_RMMOD: could be added.
|
||||
* TAINT_CPU_OUT_OF_SPEC, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't
|
||||
@@ -2792,14 +2794,17 @@ static int copy_chunked_from_user(void *dst, const void __user *usrc, unsigned l
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LIVEPATCH
|
||||
static int find_livepatch_modinfo(struct module *mod, struct load_info *info)
|
||||
static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
|
||||
{
|
||||
mod->klp = get_modinfo(info, "livepatch") ? true : false;
|
||||
if (get_modinfo(info, "livepatch")) {
|
||||
mod->klp = true;
|
||||
add_taint_module(mod, TAINT_LIVEPATCH, LOCKDEP_STILL_OK);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else /* !CONFIG_LIVEPATCH */
|
||||
static int find_livepatch_modinfo(struct module *mod, struct load_info *info)
|
||||
static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
|
||||
{
|
||||
if (get_modinfo(info, "livepatch")) {
|
||||
pr_err("%s: module is marked as livepatch module, but livepatch support is disabled",
|
||||
@@ -2969,7 +2974,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
|
||||
"is unknown, you have been warned.\n", mod->name);
|
||||
}
|
||||
|
||||
err = find_livepatch_modinfo(mod, info);
|
||||
err = check_modinfo_livepatch(mod, info);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user