From patchwork Sun Sep 3 12:07:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9936115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DEA226037D for ; Sun, 3 Sep 2017 12:09:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCC38286A9 for ; Sun, 3 Sep 2017 12:09:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1689286B3; Sun, 3 Sep 2017 12:09:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id D3787286A9 for ; Sun, 3 Sep 2017 12:09:07 +0000 (UTC) Received: (qmail 9321 invoked by uid 550); 3 Sep 2017 12:08:42 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 8060 invoked from network); 3 Sep 2017 12:08:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7y3BXLxnHPNjtMD9ykW39Ow4QRSTjd8ME9ogKXudgBw=; b=fgN9jwJUOw1QtXk/aoJ3SHlLbG6aqItsyIV6ufdNv0F40vNcSSjmO6Spq3CZsjVA5P HcmFxbFRgW+X1Oudmcg/bI+Hebb1HCiL8r2hJvtn4CmfhfZO9vvvCE6Q07nIGNMELuL8 ud9zTksTJeElBwh54zTVap7QC/hyoCCzXcbf4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7y3BXLxnHPNjtMD9ykW39Ow4QRSTjd8ME9ogKXudgBw=; b=hApGnRRwnJ87RSP0KwIX955uhN6pmOltcAtaTqa45hkMTr/Pnyf56aZ3HOpXcO9687 K8s86pL6trfeftx66JQo2pYl6CEMOVzc56b3KH4kPCcfgdSrk/9+3RNfqSL9pUj3oXUh kTCHLNMG42b5MxYF0nRd9Lejn8zWqzkLCH4OrRqrTllpfxgCsc9G6sZVKBslQMRSpFZS pxCWZe6jVSqcGhKZ3ANENDeJ1GkrH3j6Gh3gQh9QIRyzEQErj1Nr3uNFVf/2KracQq9y Z92Cgi6jvR/po+sNKhqu91sNI6WRYKdPZvsoeDCVKI+IqvFCvL69MgT2iybyYDSDk9rN hGKQ== X-Gm-Message-State: AHPjjUglWvHOH8Vrj5kEeaOSr+NkIwOKbVPrboI3JYKYFNaWwiMcxFG+ W3bq6COimnOLERse X-Google-Smtp-Source: ADKCNb4o3eaph9xco21FktFeJW08hDkzYPbPFxJoRos0996zcCKn9uzn3bn9AYj1ZzR6bKWJc/Xd3g== X-Received: by 10.28.165.203 with SMTP id o194mr1916371wme.39.1504440509228; Sun, 03 Sep 2017 05:08:29 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com Cc: Ard Biesheuvel , Arnd Bergmann , Nicolas Pitre , Russell King , Kees Cook , Thomas Garnier , Marc Zyngier , Mark Rutland , Tony Lindgren , Matt Fleming , Dave Martin Date: Sun, 3 Sep 2017 13:07:32 +0100 Message-Id: <20170903120757.14968-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170903120757.14968-1-ard.biesheuvel@linaro.org> References: <20170903120757.14968-1-ard.biesheuvel@linaro.org> Subject: [kernel-hardening] [PATCH v2 04/29] ARM: head-common.S: use PC-relative insn sequence for __proc_info X-Virus-Scanned: ClamAV using ClamSMTP Replace the open coded PC relative offset calculations with a pair of adr_l invocations. This ensures these quantities are invariant under runtime relocation. Cc: Russell King Signed-off-by: Ard Biesheuvel Acked-by: Nicolas Pitre --- arch/arm/kernel/head-common.S | 22 ++++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S index 8733012d231f..06035488130c 100644 --- a/arch/arm/kernel/head-common.S +++ b/arch/arm/kernel/head-common.S @@ -150,11 +150,12 @@ ENDPROC(lookup_processor_type) * r9 = cpuid (preserved) */ __lookup_processor_type: - adr r3, __lookup_processor_type_data - ldmia r3, {r4 - r6} - sub r3, r3, r4 @ get offset between virt&phys - add r5, r5, r3 @ convert virt addresses to - add r6, r6, r3 @ physical address space + /* + * Look in for information about the __proc_info + * structure. + */ + adr_l r5, __proc_info_begin + adr_l r6, __proc_info_end 1: ldmia r5, {r3, r4} @ value, mask and r4, r4, r9 @ mask wanted bits teq r3, r4 @@ -166,17 +167,6 @@ __lookup_processor_type: 2: ret lr ENDPROC(__lookup_processor_type) -/* - * Look in for information about the __proc_info structure. - */ - .align 2 - .type __lookup_processor_type_data, %object -__lookup_processor_type_data: - .long . - .long __proc_info_begin - .long __proc_info_end - .size __lookup_processor_type_data, . - __lookup_processor_type_data - __error_lpae: #ifdef CONFIG_DEBUG_LL adr r0, str_lpae