create-diff-object: Check for *_fixup sections changes

Currently we do not support changes to functions referring to any of the
*_fixup sections on ppc64le. This patch introduces check for such
changes during the patchability check, where we abort building the
patch module.

This patch implements the phase 1 fix of 3 phases discussed at
https://github.com/dynup/kpatch/issues/974:
"
Phase 1 fix:

For kernel versions which don't have livepatch-specific powerpc code
(currently all kernel versions), kpatch-build needs to assert an error
if it detects that one of the following sections refers to a patched
function: __ftr_fixup, __mmu_ftr_fixup, __fw_ftr_fixup.
"

Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
This commit is contained in:
Kamalesh Babulal 2019-06-25 14:46:55 +05:30
parent 09a5686277
commit bb444c2168

View File

@ -82,6 +82,7 @@ enum loglevel loglevel = NORMAL;
struct special_section { struct special_section {
char *name; char *name;
int (*group_size)(struct kpatch_elf *kelf, int offset); int (*group_size)(struct kpatch_elf *kelf, int offset);
int unsupported;
}; };
/************* /*************
@ -1913,22 +1914,27 @@ static struct special_section special_sections[] = {
{ {
.name = "__ftr_fixup", .name = "__ftr_fixup",
.group_size = fixup_entry_group_size, .group_size = fixup_entry_group_size,
.unsupported = 1,
}, },
{ {
.name = "__mmu_ftr_fixup", .name = "__mmu_ftr_fixup",
.group_size = fixup_entry_group_size, .group_size = fixup_entry_group_size,
.unsupported = 1,
}, },
{ {
.name = "__fw_ftr_fixup", .name = "__fw_ftr_fixup",
.group_size = fixup_entry_group_size, .group_size = fixup_entry_group_size,
.unsupported = 1,
}, },
{ {
.name = "__lwsync_fixup", .name = "__lwsync_fixup",
.group_size = fixup_lwsync_group_size, .group_size = fixup_lwsync_group_size,
.unsupported = 1,
}, },
{ {
.name = "__barrier_nospec_fixup", .name = "__barrier_nospec_fixup",
.group_size = fixup_barrier_nospec_group_size, .group_size = fixup_barrier_nospec_group_size,
.unsupported = 1,
}, },
#endif #endif
{}, {},
@ -2027,6 +2033,9 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf,
if (!include) if (!include)
continue; continue;
if (special->unsupported)
DIFF_FATAL("unsupported reference to special section %s", sec->base->name);
/* /*
* Copy all relas in the group. It's possible that the relas * Copy all relas in the group. It's possible that the relas
* aren't sorted (e.g. .rela.fixup), so go through the entire * aren't sorted (e.g. .rela.fixup), so go through the entire