From patchwork Tue Dec 3 07:57:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11270765 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35C4B13A4 for ; Tue, 3 Dec 2019 07:59:03 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1170A205ED for ; Tue, 3 Dec 2019 07:59:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="qbypf07P" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1170A205ED Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ic33i-0007Sy-Vg; Tue, 03 Dec 2019 07:57:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ic33h-0007St-Kg for xen-devel@lists.xenproject.org; Tue, 03 Dec 2019 07:57:21 +0000 X-Inumbo-ID: 88c2adae-15a2-11ea-81d2-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 88c2adae-15a2-11ea-81d2-12813bfff9fa; Tue, 03 Dec 2019 07:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575359841; x=1606895841; h=from:to:cc:subject:date:message-id:mime-version; bh=Mp0tzNGXgD5kIMNh5lf0e3ibqs5Z6nvc/kffxKhU9kI=; b=qbypf07PoMNvsC4UWiOT6Os07DYWDPuVo8WD3dyxqQKccfbI5bgF8ym0 6GKeYAilin0CvnbCjvuDmstcyaypeVi93xx5wlsbRpDPa888ovJ0YFlUd cyQ+YCsC1rFeOKE/LEpn1NzVpk3dfd2xwtXk3ho+4Am3gGZyN9DVUld/f M=; IronPort-SDR: yxel2GpR1dGRRlkQWLvvS87e3y2V52dIzttZtYkGqArZbsMv/rnFrT3d0912nUm1nG2OxaCwQV uvvQOiS5ArPQ== X-IronPort-AV: E=Sophos;i="5.69,272,1571702400"; d="scan'208";a="6765653" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-1c1b5cdd.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 03 Dec 2019 07:57:20 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2a-1c1b5cdd.us-west-2.amazon.com (Postfix) with ESMTPS id 45E56A119D; Tue, 3 Dec 2019 07:57:19 +0000 (UTC) Received: from EX13D05EUC001.ant.amazon.com (10.43.164.118) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 3 Dec 2019 07:57:18 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D05EUC001.ant.amazon.com (10.43.164.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 3 Dec 2019 07:57:17 +0000 Received: from dev-dsk-wipawel-1a-0c4e6d58.eu-west-1.amazon.com (10.4.134.33) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 3 Dec 2019 07:57:15 +0000 From: Pawel Wieczorkiewicz To: Date: Tue, 3 Dec 2019 07:57:09 +0000 Message-ID: <20191203075709.107811-1-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH livepatch-build-tools] create-diff-object: Ignore .init sections X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: mpohlack@amazon.de, Pawel Wieczorkiewicz , Ross Lagerwall , Konrad Rzeszutek Wilk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The .init sections must not be considered for patching regardless of whether they are CHANGED or NEW. Explicitely detect and ignore all such sections, before marking ignored sections as SAME. Signed-off-by: Pawel Wieczorkiewicz Reviewed-by: Ross Lagerwall --- common.c | 7 +++++++ common.h | 1 + create-diff-object.c | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/common.c b/common.c index 8f553ea..68a71f7 100644 --- a/common.c +++ b/common.c @@ -256,6 +256,13 @@ int is_rodata_section(struct section *sec) !strncmp(sec->name, ".rodata", 7); } +int is_init_section(struct section *sec) +{ + return sec->sh.sh_type == SHT_PROGBITS && + (sec->sh.sh_flags & SHF_ALLOC) && + !strncmp(sec->name, ".init", 5); +} + int is_debug_section(struct section *sec) { char *name; diff --git a/common.h b/common.h index b6489db..02c9b7b 100644 --- a/common.h +++ b/common.h @@ -160,6 +160,7 @@ struct symbol *find_symbol_by_name(struct list_head *list, const char *name); int is_text_section(struct section *sec); int is_rodata_section(struct section *sec); +int is_init_section(struct section *sec); int is_debug_section(struct section *sec); int is_rela_section(struct section *sec); int is_standard_section(struct section *sec); diff --git a/create-diff-object.c b/create-diff-object.c index abf3cc7..1ce5c09 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -881,6 +881,19 @@ static void kpatch_mark_ignored_functions_same(struct kpatch_elf *kelf) } } +static void livepatch_ignore_init_sections(struct kpatch_elf *kelf) +{ + struct section *sec; + + list_for_each_entry(sec, &kelf->sections, list) { + if (is_init_section(sec)) { + log_normal("WARNING: Explicitly ignoring .init section: %s\n", + sec->name); + sec->ignore = 1; + } + } +} + static void kpatch_mark_ignored_sections(struct kpatch_elf *kelf) { struct section *sec, *strsec, *ignoresec; @@ -2332,6 +2345,8 @@ int main(int argc, char *argv[]) * We access its sections via the twin pointers in the * section, symbol, and rela lists of kelf_patched. */ + log_debug("Ignore .init sections\n"); + livepatch_ignore_init_sections(kelf_patched); log_debug("Mark ignored sections\n"); kpatch_mark_ignored_sections(kelf_patched); log_debug("Compare correlated elements\n");