From patchwork Mon Aug 14 12:53:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9898803 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 33A12602BA for ; Mon, 14 Aug 2017 12:56:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28730285E3 for ; Mon, 14 Aug 2017 12:56:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CEA428602; Mon, 14 Aug 2017 12:56:07 +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 36680285E3 for ; Mon, 14 Aug 2017 12:56:06 +0000 (UTC) Received: (qmail 22152 invoked by uid 550); 14 Aug 2017 12:55:10 -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 19470 invoked from network); 14 Aug 2017 12:54:54 -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=zlboNm/Dz+QHErR9YXIMWDbt/5JEH8elUkiSpKHh3+U=; b=R+jGT4G3DQG/yJWaqiMMAryGpM+mBY2UjpA/l2eEORoyCyM0z2BlnDbFjJ06N4HHhS dpFoDBuhkPIpW1mm6TI8K9mBpyGZc9l89DlmsAjo8omWZvTS7VLUEvx7RK81BLcUSXQ2 wy7IG1Y+Ue/++y7Xnv40pKBDOJLX0gRmebrOE= 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=zlboNm/Dz+QHErR9YXIMWDbt/5JEH8elUkiSpKHh3+U=; b=PIH1/w+7RP7QRec3kBh8g/x7GBYkbb3nl9MNF9CUF+onwcCM5/kVuGZ+O8Sk3ifXvX xOa+2gPIfdAe671f6Wi2HDgz+dMsFJ0sqk2IRcSqI35PLSkIskXUMMuVp4IV/uAQ/K5W Csi5u0BSjkmylrY16qiCuC2lNl95bDe2LfMwSgTxuFhZTD8tF7JQ1JzHPnNrnMNJpvac eRVYwcl0tWE0pwpht7LtBsxLdBeZcKGlmEa+Ba+jb1LwX127zyojRnhtIpd0E4MaAlXz 7NLlAf2vgLh/Rta5p+XGYUqyxNt8aXWbkwoDmBZh+EfUMb+Bm8fOlf016aILO7pvFaDw rZsQ== X-Gm-Message-State: AHYfb5iG6OoDNXHbhzti8xo2Foec4kS+s57L9CW/XMnUumHOTt0D+Zur 76GyGjZRobHOMC/yGMtCOw== X-Received: by 10.223.143.47 with SMTP id p44mr1538199wrb.120.1502715282984; Mon, 14 Aug 2017 05:54:42 -0700 (PDT) From: Ard Biesheuvel To: kernel-hardening@lists.openwall.com Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Arnd Bergmann , Nicolas Pitre , Russell King , Kees Cook , Thomas Garnier , Marc Zyngier , Mark Rutland , Tony Lindgren , Matt Fleming , Dave Martin Date: Mon, 14 Aug 2017 13:53:46 +0100 Message-Id: <20170814125411.22604-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170814125411.22604-1-ard.biesheuvel@linaro.org> References: <20170814125411.22604-1-ard.biesheuvel@linaro.org> Subject: [kernel-hardening] [PATCH 05/30] ARM: head.S: use PC-relative insn sequence for secondary_data X-Virus-Scanned: ClamAV using ClamSMTP Replace the open coded PC relative offset calculations with adr_l and ldr_l invocations. This ensures these quantities are invariant under runtime relocation. Cc: Russell King Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/head.S | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 0a98aec0e39d..6e9df3663a57 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -386,10 +386,8 @@ ENTRY(secondary_startup) /* * Use the page tables supplied from __cpu_up. */ - adr r4, __secondary_data - ldmia r4, {r5, r7, r12} @ address to jump to after - sub lr, r4, r5 @ mmu has been enabled - add r3, r7, lr + adr_l r3, secondary_data + mov_l r12, __secondary_switched ldrd r4, [r3, #0] @ get secondary_data.pgdir ARM_BE8(eor r4, r4, r5) @ Swap r5 and r4 in BE: ARM_BE8(eor r5, r4, r5) @ it can be done in 3 steps @@ -404,22 +402,13 @@ ARM_BE8(eor r4, r4, r5) @ without using a temp reg. ENDPROC(secondary_startup) ENDPROC(secondary_startup_arm) - /* - * r6 = &secondary_data - */ ENTRY(__secondary_switched) - ldr sp, [r7, #12] @ get secondary_data.stack + ldr_l r7, secondary_data + 12 @ get secondary_data.stack + mov sp, r7 mov fp, #0 b secondary_start_kernel ENDPROC(__secondary_switched) - .align - - .type __secondary_data, %object -__secondary_data: - .long . - .long secondary_data - .long __secondary_switched #endif /* defined(CONFIG_SMP) */