Merge pull request #413 from jpoimboe/static-fix

skip data sections when looking for users of static locals
This commit is contained in:
Seth Jennings 2014-09-11 13:22:51 -05:00
commit 671a30fb99
2 changed files with 28 additions and 1 deletions

View File

@ -182,6 +182,12 @@ int is_rela_section(struct section *sec)
return (sec->sh.sh_type == SHT_RELA); return (sec->sh.sh_type == SHT_RELA);
} }
int is_text_section(struct section *sec)
{
return (sec->sh.sh_type == SHT_PROGBITS &&
(sec->sh.sh_flags & SHF_EXECINSTR));
}
int is_debug_section(struct section *sec) int is_debug_section(struct section *sec)
{ {
char *name; char *name;
@ -904,6 +910,7 @@ void kpatch_correlate_static_local_variables(struct kpatch_elf *base,
sec = NULL; sec = NULL;
list_for_each_entry(tmpsec, &patched->sections, list) { list_for_each_entry(tmpsec, &patched->sections, list) {
if (!is_rela_section(tmpsec) || if (!is_rela_section(tmpsec) ||
!is_text_section(tmpsec->base) ||
is_debug_section(tmpsec)) is_debug_section(tmpsec))
continue; continue;
list_for_each_entry(rela, &tmpsec->relas, list) { list_for_each_entry(rela, &tmpsec->relas, list) {
@ -1045,7 +1052,7 @@ void kpatch_replace_sections_syms(struct kpatch_elf *kelf)
strcmp(rela->sym->name, ".data..read_mostly") && strcmp(rela->sym->name, ".data..read_mostly") &&
strcmp(rela->sym->name, ".data.unlikely") && strcmp(rela->sym->name, ".data.unlikely") &&
!(rela->sym->type == STT_SECTION && rela->sym->sec && !(rela->sym->type == STT_SECTION && rela->sym->sec &&
(rela->sym->sec->sh.sh_flags & SHF_EXECINSTR))) is_text_section(rela->sym->sec)))
continue; continue;
list_for_each_entry(sym, &kelf->symbols, list) { list_for_each_entry(sym, &kelf->symbols, list) {

View File

@ -0,0 +1,20 @@
Index: src/kernel/reboot.c
===================================================================
--- src.orig/kernel/reboot.c
+++ src/kernel/reboot.c
@@ -285,8 +285,15 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
return ret;
}
+void kpatch_foo(void)
+{
+ if (!jiffies)
+ printk("kpatch_foo\n");
+}
+
static void deferred_cad(struct work_struct *dummy)
{
+ kpatch_foo();
kernel_restart(NULL);
}