@@ -114,7 +114,20 @@ bool_t arch_livepatch_symbol_ok(const struct livepatch_elf *elf,
}
return true;
}
-
+int arch_livepatch_symbol_check(const struct livepatch_elf *elf,
+ const struct livepatch_elf_sym *sym)
+{
+#ifdef CONFIG_ARM_32
+ /*
+ * Xen does not use Thumb instructions - and we should not see any of
+ * them. If we do, abort.
+ */
+ if ( *sym->name == '$' && sym->name[1] == 't' )
+ return -EINVAL;
+#else
+ return 0;
+#endif
+}
int arch_livepatch_perform_rel(struct livepatch_elf *elf,
const struct livepatch_elf_sec *base,
const struct livepatch_elf_sec *rela)
@@ -137,6 +137,13 @@ bool_t arch_livepatch_symbol_ok(const struct livepatch_elf *elf,
return true;
}
+int arch_livepatch_symbol_check(const struct livepatch_elf *elf,
+ const struct livepatch_elf_sym *sym)
+{
+ /* No special checks on x86. */
+ return 0;
+}
+
int arch_livepatch_perform_rel(struct livepatch_elf *elf,
const struct livepatch_elf_sec *base,
const struct livepatch_elf_sec *rela)
@@ -244,6 +244,7 @@ static int elf_get_sym(struct livepatch_elf *elf, const void *data)
for ( i = 1; i < nsym; i++ )
{
const Elf_Sym *s = symtab_sec->data + symtab_sec->sec->sh_entsize * i;
+ int rc;
delta = s->st_name;
/* Boundary check within the .strtab. */
@@ -256,6 +257,14 @@ static int elf_get_sym(struct livepatch_elf *elf, const void *data)
sym[i].sym = s;
sym[i].name = strtab_sec->data + delta;
+ /* On ARM we should NEVER see $t* symbols. */
+ rc = arch_livepatch_symbol_check(elf, sym);
+ if ( rc )
+ {
+ dprintk(XENLOG_ERR, LIVEPATCH "%s: Symbol '%s' should not be in payload!\n",
+ elf->name, sym[i].name);
+ return rc;
+ }
}
elf->nsym = nsym;
@@ -48,6 +48,8 @@ int arch_verify_insn_length(unsigned long len);
int arch_livepatch_verify_elf(const struct livepatch_elf *elf);
bool_t arch_livepatch_symbol_ok(const struct livepatch_elf *elf,
const struct livepatch_elf_sym *sym);
+int arch_livepatch_symbol_check(const struct livepatch_elf *elf,
+ const struct livepatch_elf_sym *sym);
int arch_livepatch_perform_rel(struct livepatch_elf *elf,
const struct livepatch_elf_sec *base,
const struct livepatch_elf_sec *rela);