提交 12326136 编写于 作者: Z Zheng Yejian 提交者: Zheng Zengkai

livepatch/core: Fix where module get and put in different macro

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SFHQ

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

Refer to following function procedure, 'obj->mod' is got if not define
CONFIG_LIVEPATCH_FTRACE, but it is put if define
CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY. If enable state of these two
macros changed, reference count of 'obj->mod' would be wrong.

  klp_register_patch
      klp_init_patch
          klp_init_object
              klp_find_object_module
                  try_module_get    <-- !CONFIG_LIVEPATCH_FTRACE
              module_put  <-- CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
      klp_free_patch_start
          klp_free_objects
              __klp_free_objects
                  module_put <-- CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY

So we use CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY uniformly.

Fixes: c33e4283 ("livepatch/core: Allow implementation without ftrace")
Signed-off-by: NZheng Yejian <zhengyejian1@huawei.com>
Reviewed-by: NXu Kuohai <xukuohai@huawei.com>
Reviewed-by: NCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 70e6a87c
......@@ -122,10 +122,7 @@ static int klp_find_object_module(struct klp_object *obj)
* until mod->exit() finishes. This is especially important for
* patches that modify semantic of the functions.
*/
#ifdef CONFIG_LIVEPATCH_FTRACE
if (mod && mod->klp_alive)
obj->mod = mod;
#else
#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
if (!mod) {
pr_err("module '%s' not loaded\n", obj->name);
mutex_unlock(&module_mutex);
......@@ -138,6 +135,9 @@ static int klp_find_object_module(struct klp_object *obj)
}
obj->mod = mod;
#else
if (mod && mod->klp_alive)
obj->mod = mod;
#endif
mutex_unlock(&module_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册