livepatch: do not ignore sections with 0 size
authorRoger Pau Monné <roger.pau@citrix.com>
Fri, 8 Apr 2022 08:24:10 +0000 (10:24 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 8 Apr 2022 08:24:10 +0000 (10:24 +0200)
commit0dc1f929e8fed681dec09ca3ea8de38202d5bf30
tree082c9bed8d3ccaed9aba3e454fd825040fcdfcab
parentd3f61beea4255e2d86ae82303384c57a3262435e
livepatch: do not ignore sections with 0 size

A side effect of ignoring such sections is that symbols belonging to
them won't be resolved, and that could make relocations belonging to
other sections that reference those symbols fail.

For example it's likely to have an empty .altinstr_replacement with
symbols pointing to it, and marking the section as ignored will
prevent the symbols from being resolved, which in turn will cause any
relocations against them to fail.

In order to solve this do not ignore sections with 0 size, only ignore
sections that don't have the SHF_ALLOC flag set.

Special case such empty sections in move_payload so they are not taken
into account in order to decide whether a livepatch can be safely
re-applied after a revert.

Fixes: 98b728a7b2 ('livepatch: Disallow applying after an revert')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Tested-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
xen/common/livepatch.c
xen/include/xen/livepatch_elf.h