mirror of
https://github.com/dynup/kpatch
synced 2025-02-16 09:36:55 +00:00
kpatch-build: strengthen conditions for changed sections
If two sections want to be the same, they need to satisfy two conditions: 1) the result of memcmp is zero, which means they have the same content. 2) they have the same relocation entries. In one specific situation, two sections have the same content. But one section has relocation entries while the other one has no relocation entries. For example, in X86, consider the following code: original code ``` __noreturn noinline int kpatch_func(void) { while(1) {}; } ``` patched code ``` __noreturn notrace noinline int kpatch_func(void) { asm(".byte 0xe8, 0x00, 0x00, 0x00, 0x00"); while(1){}; } ``` Since the original code has a fentry call, these two functions have the same compile result. But obviously, they are different functions. Currently, kpatch would not find their differences since the patched code has no relocation entries. For the situation that one section has relocation entries while the other one doesn't have, it should be set to be changed directly. Cooperated-by: Zongwu Li <lizongwu@huawei.com> Signed-off-by: Longjun Luo <luolongjuna@gmail.com>
This commit is contained in:
parent
80fc15ac36
commit
d46fea98ef
@ -579,7 +579,9 @@ static void kpatch_compare_correlated_section(struct section *sec)
|
||||
}
|
||||
|
||||
if (sec1->sh.sh_size != sec2->sh.sh_size ||
|
||||
sec1->data->d_size != sec2->data->d_size) {
|
||||
sec1->data->d_size != sec2->data->d_size ||
|
||||
(sec1->rela && !sec2->rela) ||
|
||||
(sec2->rela && !sec1->rela)) {
|
||||
sec->status = CHANGED;
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user