提交 e6a47cb4 编写于 作者: Z Zhao Xuehui 提交者: Yang Yingliang

livepatch/x86_64: Fix the deadlock when insmoding livepatch kernel module

hulk inclusion
category: bugfix
bugzilla: 51843
CVE: NA

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

In function klp_init_patch, a text_mutex lock is used when
doing jump_label_apply_nops. However, the jump_label_register
in which a text_mutex lock is used is done before the original
text_mutex lock released. Thus, an AA deadlock is occured.

In this commit, we do jump_label_register after the original
text_mutex lock is released to avoid this AA deadlock.
Signed-off-by: NZhao Xuehui <zhaoxuehui1@huawei.com>
Reviewed-by: NKuohai Xu <xukuohai@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 70320991
......@@ -1207,14 +1207,12 @@ static int klp_init_patch(struct klp_patch *patch)
mutex_lock(&text_mutex);
module_disable_ro(patch->mod);
jump_label_apply_nops(patch->mod);
module_enable_ro(patch->mod, true);
mutex_unlock(&text_mutex);
ret = jump_label_register(patch->mod);
if (ret) {
module_enable_ro(patch->mod, true);
mutex_unlock(&text_mutex);
goto free;
}
module_enable_ro(patch->mod, true);
mutex_unlock(&text_mutex);
#ifdef CONFIG_LIVEPATCH_WO_FTRACE
klp_for_each_object(patch, obj)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册