[PATCH 0/2] livepatch: fix handling of (some) relocations

Roger Pau Monne posted 2 patches 2 years, 1 month ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20220317110854.39050-1-roger.pau@citrix.com
xen/arch/arm/arm32/livepatch.c  |  7 +++++++
xen/arch/arm/arm64/livepatch.c  |  7 +++++++
xen/arch/x86/livepatch.c        |  7 +++++++
xen/common/livepatch.c          | 16 +++++++++++-----
xen/common/livepatch_elf.c      |  6 ++++++
xen/include/xen/livepatch_elf.h |  3 ++-
6 files changed, 40 insertions(+), 6 deletions(-)
[PATCH 0/2] livepatch: fix handling of (some) relocations
Posted by Roger Pau Monne 2 years, 1 month ago
Hello,

Relocations that reference symbols that belong to sections with a size
of 0 are not properly resolved, as the address of those symbols won't be
resolved in the first place.

Fix this by not ignoring sections with a size of 0, while still properly
handling the detection of whether a livepatch can be reapplied after
being reverted (patch 1).

Also detect whether any relocations reference unresolved symbols and
error out in that case, as those relocations cannot be resolved (patch
2).

I wonder whether it's possible to have unresolved symbols if we only
ignore non SHF_ALLOC sections, so we could maybe error out earlier if we
found a symbols that belongs to a non SHF_ALLOC section in
livepatch_elf_resolve_symbols.  The current approach is more conservative
as we would only report an error if we have unresolved symbols that are
referenced in relocations.

Thanks, Roger.

Roger Pau Monne (2):
  livepatch: do not ignore sections with 0 size
  livepatch: avoid relocations referencing ignored section symbols

 xen/arch/arm/arm32/livepatch.c  |  7 +++++++
 xen/arch/arm/arm64/livepatch.c  |  7 +++++++
 xen/arch/x86/livepatch.c        |  7 +++++++
 xen/common/livepatch.c          | 16 +++++++++++-----
 xen/common/livepatch_elf.c      |  6 ++++++
 xen/include/xen/livepatch_elf.h |  3 ++-
 6 files changed, 40 insertions(+), 6 deletions(-)

-- 
2.34.1
Re: [PATCH 0/2] livepatch: fix handling of (some) relocations
Posted by Jan Beulich 2 years, 1 month ago
On 17.03.2022 12:08, Roger Pau Monne wrote:
> I wonder whether it's possible to have unresolved symbols if we only
> ignore non SHF_ALLOC sections, so we could maybe error out earlier if we
> found a symbols that belongs to a non SHF_ALLOC section in
> livepatch_elf_resolve_symbols.  The current approach is more conservative
> as we would only report an error if we have unresolved symbols that are
> referenced in relocations.

I think it's better to remain that way. Symbols appearing in non-alloc
sections isn't wrong in any way, as long - as you say - there's no
relocation using them.

Jan