提交 78572aab 编写于 作者: C Cheng Jian 提交者: Xie XiuQi

livepatch/core: change module_get/put under STOP_MACHINE_CONSISTENCY

euler inclusion
category: bugfix
Bugzilla: 9287/5507
CVE: N/A

----------------------------------------

module_get/put should protected by STOP_MACHINE_CONSISTENCY

fix commit 49e30bb60ea ("livepatch/core: split livepatch consistency")
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
Reviewed-by: NZhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 7e085ad4
...@@ -127,10 +127,10 @@ static int klp_find_object_module(struct klp_object *obj) ...@@ -127,10 +127,10 @@ static int klp_find_object_module(struct klp_object *obj)
* until mod->exit() finishes. This is especially important for * until mod->exit() finishes. This is especially important for
* patches that modify semantic of the functions. * patches that modify semantic of the functions.
*/ */
#ifdef CONFIG_LIVEPATCH_FTRACE #ifdef CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY
if (mod && mod->klp_alive) if (mod && mod->klp_alive)
obj->mod = mod; obj->mod = mod;
#else #elif defined(CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY)
if (!mod) { if (!mod) {
pr_err("module '%s' not loaded\n", obj->name); pr_err("module '%s' not loaded\n", obj->name);
mutex_unlock(&module_mutex); mutex_unlock(&module_mutex);
...@@ -141,7 +141,7 @@ static int klp_find_object_module(struct klp_object *obj) ...@@ -141,7 +141,7 @@ static int klp_find_object_module(struct klp_object *obj)
} else { } else {
obj->mod = mod; obj->mod = mod;
} }
#endif /* ifdef CONFIG_LIVEPATCH_FTRACE */ #endif /* ifdef CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY */
mutex_unlock(&module_mutex); mutex_unlock(&module_mutex);
return 0; return 0;
...@@ -979,9 +979,10 @@ static void klp_free_objects_limited(struct klp_patch *patch, ...@@ -979,9 +979,10 @@ static void klp_free_objects_limited(struct klp_patch *patch,
struct klp_object *obj; struct klp_object *obj;
for (obj = patch->objs; obj->funcs && obj != limit; obj++) { for (obj = patch->objs; obj->funcs && obj != limit; obj++) {
#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
if (klp_is_module(obj)) if (klp_is_module(obj))
module_put(obj->mod); module_put(obj->mod);
#endif
klp_free_funcs_limited(obj, NULL); klp_free_funcs_limited(obj, NULL);
kobject_put(&obj->kobj); kobject_put(&obj->kobj);
} }
...@@ -1130,7 +1131,9 @@ static int klp_init_object(struct klp_patch *patch, struct klp_object *obj) ...@@ -1130,7 +1131,9 @@ static int klp_init_object(struct klp_patch *patch, struct klp_object *obj)
out: out:
kobject_put(&obj->kobj); kobject_put(&obj->kobj);
put: put:
#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
module_put(obj->mod); module_put(obj->mod);
#endif
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册