mirror of
https://github.com/dynup/kpatch
synced 2025-02-19 19:26:53 +00:00
Merge pull request #1332 from sumanthkorikkar/ubsan-support
support ubsan for kpatch
This commit is contained in:
commit
831a22bd1c
@ -1036,6 +1036,9 @@ static void kpatch_correlate_sections(struct list_head *seclist_orig,
|
||||
sec_patched->twin)
|
||||
continue;
|
||||
|
||||
if (is_ubsan_sec(sec_orig->name))
|
||||
continue;
|
||||
|
||||
if (is_special_static(is_rela_section(sec_orig) ?
|
||||
sec_orig->base->secsym :
|
||||
sec_orig->secsym))
|
||||
@ -1072,6 +1075,9 @@ static void kpatch_correlate_symbols(struct list_head *symlist_orig,
|
||||
sym_orig->type != sym_patched->type || sym_patched->twin)
|
||||
continue;
|
||||
|
||||
if (is_ubsan_sec(sym_orig->name))
|
||||
continue;
|
||||
|
||||
if (is_special_static(sym_orig))
|
||||
continue;
|
||||
|
||||
@ -1547,6 +1553,13 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf)
|
||||
if (rela->sym->type != STT_SECTION || !rela->sym->sec)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* UBSAN data will be taken wholesale, no need to
|
||||
* replace section symbols.
|
||||
*/
|
||||
if (is_ubsan_sec(rela->sym->name))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* These sections don't have symbols associated with
|
||||
* them:
|
||||
|
@ -587,6 +587,18 @@ bool is_local_sym(struct symbol *sym)
|
||||
return sym->bind == STB_LOCAL;
|
||||
}
|
||||
|
||||
bool is_ubsan_sec(const char *name) {
|
||||
if (!strncmp(name, ".data.rel.local..Lubsan_data", 28) ||
|
||||
!strncmp(name, ".data..Lubsan_type", 18) ||
|
||||
!strncmp(name, ".Lubsan_data", 12) ||
|
||||
!strncmp(name, ".data..Lubsan_data", 18) ||
|
||||
!strncmp(name, ".rela.data..Lubsan_data", 23) ||
|
||||
!strncmp(name, ".rela.data.rel.local..Lubsan_data", 33))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void print_strtab(char *buf, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -170,6 +170,7 @@ bool is_null_sym(struct symbol *sym);
|
||||
bool is_file_sym(struct symbol *sym);
|
||||
bool is_local_func_sym(struct symbol *sym);
|
||||
bool is_local_sym(struct symbol *sym);
|
||||
bool is_ubsan_sec(const char *name);
|
||||
|
||||
void print_strtab(char *buf, size_t size);
|
||||
void kpatch_create_shstrtab(struct kpatch_elf *kelf);
|
||||
|
@ -84,7 +84,8 @@ static bool maybe_discarded_sym(const char *name)
|
||||
!strncmp(name, "__func_stack_frame_non_standard_", 32) ||
|
||||
strstr(name, "__addressable_") ||
|
||||
strstr(name, "__UNIQUE_ID_") ||
|
||||
!strncmp(name, ".L.str", 6))
|
||||
!strncmp(name, ".L.str", 6) ||
|
||||
is_ubsan_sec(name))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user