xen/livepatch: Don't crash on encountering STN_UNDEF relocations
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 13 Jun 2017 20:36:58 +0000 (21:36 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 23 Jun 2017 14:00:37 +0000 (15:00 +0100)
commit2ff229643b739e2fd0cd0536ee9fca506cfa92f8
treeae8afe14f1272553274bcc60eb84ea09ccfd32d3
parentbd53b85156aaf0330181ab9b82d9a6c52fb30f8c
xen/livepatch: Don't crash on encountering STN_UNDEF relocations

A symndx of STN_UNDEF is special, and means a symbol value of 0.  While
legitimate in the ELF standard, its existance in a livepatch is questionable
at best.  Until a plausible usecase presents itself, reject such a relocation
with -EOPNOTSUPP.

Additionally, fix an off-by-one error while range checking symndx, and perform
a safety check on elf->sym[symndx].sym before derefencing it, to avoid
tripping over a NULL pointer when calculating val.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> [x86 and arm32]
Reviewed-by: Jan Beulich <JBeulich@suse.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
xen/arch/arm/arm32/livepatch.c
xen/arch/arm/arm64/livepatch.c
xen/arch/x86/livepatch.c