Commit a27c2643 authored by Zheng Yejian's avatar Zheng Yejian Committed by Zheng Zengkai
Browse files

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: default avatarXu Kuohai <xukuohai@huawei.com>
Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
Reviewed-by: default avatarKuohai Xu <xukuohai@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent e3857414
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment