mirror of
https://github.com/dynup/kpatch
synced 2025-02-20 03:36:52 +00:00
kpatch-elf: Ensure stale references are not used
When freeing a kpatch_elf, another object might have symbols and sections twined with elements that are getting freed. Clear the twin references, so if they are used after the object they reference is freed, the program will crash. Signed-off-by: Julien Thierry <jthierry@redhat.com>
This commit is contained in:
parent
e0bd024c18
commit
770f529225
@ -847,6 +847,8 @@ void kpatch_elf_teardown(struct kpatch_elf *kelf)
|
||||
struct rela *rela, *saferela;
|
||||
|
||||
list_for_each_entry_safe(sec, safesec, &kelf->sections, list) {
|
||||
if (sec->twin)
|
||||
sec->twin->twin = NULL;
|
||||
if (is_rela_section(sec)) {
|
||||
list_for_each_entry_safe(rela, saferela, &sec->relas, list) {
|
||||
memset(rela, 0, sizeof(*rela));
|
||||
@ -858,6 +860,8 @@ void kpatch_elf_teardown(struct kpatch_elf *kelf)
|
||||
}
|
||||
|
||||
list_for_each_entry_safe(sym, safesym, &kelf->symbols, list) {
|
||||
if (sym->twin)
|
||||
sym->twin->twin = NULL;
|
||||
memset(sym, 0, sizeof(*sym));
|
||||
free(sym);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user