livepatch/x86: Fix incorrect use of 'strncpy'
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4UAQ1 -------------------------------- 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". > 396 static void *klp_old_code(unsigned char *code) > 397 { > 398 static unsigned char old_code[JMP_E9_INSN_SIZE]; > 399 > 400 strncpy(old_code, code, JMP_E9_INSN_SIZE); > 401 return old_code; > 402 } As a result, the instructions cannot be restored completely, and the system becomes abnormal. Fixes: f5a67467 ("livepatch/x86: support livepatch without ftrace") Suggested-by: NXu Kuohai <xukuohai@huawei.com> Signed-off-by: NZheng Yejian <zhengyejian1@huawei.com> Reviewed-by: NKuohai Xu <xukuohai@huawei.com> Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Showing
想要评论请 注册 或 登录