Skip to content
Snippets Groups Projects
Commit 2f75922c authored by Zheng Yejian's avatar Zheng Yejian Committed by Yang Yingliang
Browse files

livepatch/x86: Fix incorrect use of 'strncpy'

hulk inclusion
category: bugfix
bugzilla: 186253, https://gitee.com/openeuler/kernel/issues/I4TYA9


CVE: NA

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

Refer to following codes, 'strncpy' would stop copying if Null character
encountered. For example, when 'code' is "53 be 00 0a 05", 'old_code'
would be "53 be 00 00 00".
    > 276 static unsigned char *klp_old_code(unsigned char *code)
    > 277 {
    > 278         static union klp_code_union old_code;
    > 279
    > 280         strncpy(old_code.code, code, JMP_E9_INSN_SIZE);
    > 281         return old_code.code;
    > 282 }

As a result, the instructions cannot be restored completely, and the
system becomes abnormal.

Fixes: 7e2ab91e ("livepatch/x86: support livepatch without ftrace")
Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
Reviewed-by: default avatarKuohai Xu <xukuohai@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 527f1d87
No related branches found
No related tags found
No related merge requests found
......@@ -277,7 +277,7 @@ static unsigned char *klp_old_code(unsigned char *code)
{
static union klp_code_union old_code;
strncpy(old_code.code, code, JMP_E9_INSN_SIZE);
memcpy(old_code.code, code, JMP_E9_INSN_SIZE);
return old_code.code;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment