livepatch: avoid relocations referencing ignored section symbols

Track whether symbols belong to ignored sections in order to avoid
applying relocations referencing those symbols. The address of such
symbols won't be resolved and thus the relocation will likely fail or
write garbage to the destination.

Return an error in that case, as leaving unresolved relocations would
lead to malfunctioning payload code.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Tested-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
master commit: 9120b5737f
master date: 2022-04-08 10:27:11 +0200
This commit is contained in:
Roger Pau Monné authored and Jan Beulich committed 2022-04-08 14:59:27 +02:00
1 parent 46d80ba371
commit b953760d0b
5 files changed
+28

No files matched your search

+7
View File
@@ -272,6 +272,13 @@ int arch_livepatch_perform(struct livepatch_elf *elf,
elf->name, symndx);
return -EINVAL;
}
else if ( elf->sym[symndx].ignored )
{
printk(XENLOG_ERR LIVEPATCH
"%s: Relocation against ignored symbol %s cannot be resolved\n",
elf->name, elf->sym[symndx].name);
return -EINVAL;
}
val = elf->sym[symndx].sym->st_value; /* S */
+7
View File
@@ -270,6 +270,13 @@ int arch_livepatch_perform_rela(struct livepatch_elf *elf,
elf->name, symndx);
return -EINVAL;
}
else if ( elf->sym[symndx].ignored )
{
printk(XENLOG_ERR LIVEPATCH
"%s: Relocation against ignored symbol %s cannot be resolved\n",
elf->name, elf->sym[symndx].name);
return -EINVAL;
}
val = elf->sym[symndx].sym->st_value + r->r_addend; /* S+A */
+7
View File
@@ -290,6 +290,13 @@ int arch_livepatch_perform_rela(struct livepatch_elf *elf,
elf->name, symndx);
return -EINVAL;
}
else if ( elf->sym[symndx].ignored )
{
printk(XENLOG_ERR LIVEPATCH
"%s: Relocation against ignored symbol %s cannot be resolved\n",
elf->name, elf->sym[symndx].name);
return -EINVAL;
}
val = r->r_addend + elf->sym[symndx].sym->st_value;
+6
View File
@@ -334,7 +334,13 @@ int livepatch_elf_resolve_symbols(struct livepatch_elf *elf)
}
if ( livepatch_elf_ignore_section(elf->sec[idx].sec) )
{
dprintk(XENLOG_DEBUG, LIVEPATCH
"%s: Symbol %s from section %s ignored\n",
elf->name, elf->sym[i].name, elf->sec[idx].name);
elf->sym[i].ignored = true;
break;
}
st_value += (unsigned long)elf->sec[idx].load_addr;
if ( elf->sym[i].name )
+1
View File
@@ -22,6 +22,7 @@ struct livepatch_elf_sec {
struct livepatch_elf_sym {
const Elf_Sym *sym;
const char *name;
bool ignored;
};
struct livepatch_elf {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.