mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
livepatch/arm/x86: Check payload for for unwelcomed symbols.
Certain platforms, such as ARM [32|64] add extra mapping symbols such as $x (for ARM64 instructions), or more interesting to this patch: $t (for Thumb instructions). These symbols are supposed to help the final linker to make any adjustments (such as add an veneer). But more importantly - we do not compile Xen with any Thumb instructions (which are variable length) - and if we find these mapping symbols we should disallow such payload. Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com> Reviewed-by: Julien Grall <julien.grall@arm.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
This commit is contained in:
1 parent
725e8e66c6
commit
e04977e0c0
5 files changed
+35
No files matched your search
@@ -20,6 +20,19 @@ int arch_livepatch_verify_elf(const struct livepatch_elf *elf)
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
bool arch_livepatch_symbol_deny(const struct livepatch_elf *elf,
|
||||
const struct livepatch_elf_sym *sym)
|
||||
{
|
||||
/*
|
||||
* Xen does not use Thumb instructions - and we should not see any of
|
||||
* them. If we do, abort.
|
||||
*/
|
||||
if ( sym->name && sym->name[0] == '$' && sym->name[1] == 't' )
|
||||
return ( !sym->name[2] || sym->name[2] == '.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int arch_livepatch_perform_rela(struct livepatch_elf *elf,
|
||||
const struct livepatch_elf_sec *base,
|
||||
const struct livepatch_elf_sec *rela)
|
||||
|
||||
@@ -90,6 +90,13 @@ int arch_livepatch_verify_elf(const struct livepatch_elf *elf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool arch_livepatch_symbol_deny(const struct livepatch_elf *elf,
|
||||
const struct livepatch_elf_sym *sym)
|
||||
{
|
||||
/* No special checks on ARM 64. */
|
||||
return false;
|
||||
}
|
||||
|
||||
enum aarch64_reloc_op {
|
||||
RELOC_OP_NONE,
|
||||
RELOC_OP_ABS,
|
||||
|
||||
@@ -131,6 +131,13 @@ bool arch_livepatch_symbol_ok(const struct livepatch_elf *elf,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool arch_livepatch_symbol_deny(const struct livepatch_elf *elf,
|
||||
const struct livepatch_elf_sym *sym)
|
||||
{
|
||||
/* No special checks on x86. */
|
||||
return false;
|
||||
}
|
||||
|
||||
int arch_livepatch_perform_rel(struct livepatch_elf *elf,
|
||||
const struct livepatch_elf_sec *base,
|
||||
const struct livepatch_elf_sec *rela)
|
||||
|
||||
@@ -251,6 +251,12 @@ static int elf_get_sym(struct livepatch_elf *elf, const void *data)
|
||||
|
||||
sym[i].sym = s;
|
||||
sym[i].name = strtab_sec->data + delta;
|
||||
if ( arch_livepatch_symbol_deny(elf, &sym[i]) )
|
||||
{
|
||||
dprintk(XENLOG_ERR, LIVEPATCH "%s: Symbol '%s' should not be in payload!\n",
|
||||
elf->name, sym[i].name);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
elf->nsym = nsym;
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ bool_t is_patch(const void *addr);
|
||||
int arch_livepatch_verify_elf(const struct livepatch_elf *elf);
|
||||
bool arch_livepatch_symbol_ok(const struct livepatch_elf *elf,
|
||||
const struct livepatch_elf_sym *sym);
|
||||
bool arch_livepatch_symbol_deny(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);
|
||||
|
||||