From 303928f634739ab8ef04e276beaa9323bb3d3b4d Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Fri, 30 May 2014 08:06:40 -0500 Subject: [PATCH] create-diff-object: ensure no data sections are included When a changed function needs relocations for special data sections like .data..percpu or .data..read_mostly, it's possible for those sections to get included. We try to avoid that situation by converting section references to data symbol references in kpatch_replace_sections_syms(), but the conversion success rate isn't 100%, and we could be forgetting about some other sections, so ensure that it never happens in kpatch_verify_patchability(). --- kpatch-build/create-diff-object.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 72ac26a..144399c 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -790,12 +790,23 @@ void kpatch_verify_patchability(struct kpatch_elf *kelf) struct section *sec; int errs = 0; - list_for_each_entry(sec, &kelf->sections, list) + list_for_each_entry(sec, &kelf->sections, list) { if (sec->status == CHANGED && !sec->include) { log_normal("%s: changed section %s not selected for inclusion\n", objname, sec->name); errs++; } + + /* ensure we aren't including .data.* or .bss.* */ + if (sec->include && + (!strncmp(sec->name, ".data", 5) || + !strncmp(sec->name, ".bss", 4))) { + log_normal("%s: data section %s selected for inclusion\n", + objname, sec->name); + errs++; + } + } + if (errs) DIFF_FATAL("%d unsupported section change(s)", errs); }