Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp902341yba; Thu, 18 Apr 2019 11:30:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH/+tusqMK6tqpNxYOrEMWN0lmm+EHkevtt/wFqwAyMmHtWuraVbAWATb0xPHNW/c8Y81c X-Received: by 2002:a17:902:8bca:: with SMTP id r10mr96875743plo.67.1555612208259; Thu, 18 Apr 2019 11:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555612208; cv=none; d=google.com; s=arc-20160816; b=H5+HeJGL0MBHc9odcN8zHoEfpQwy+tEwwHb4a7HrR9NXRtMOZSuxWmCQCvPRtFT3C6 zNr7D5gaKTkTYnMJRoKnCtea6onNi68cI39Kzslz9nAcrs8PmpAlzRFOjkbirM/uRj9U NzBuMqsLE/IuAvXItd4k9mow2B4vbud78CShr/QeevGLChryYkFTI5LHvRGCDEwJA/xs IMzr407PydruaeZGtYFTfPMQuJed5VhyWKOwnW3RDe2XWGcdP+6DR5Ka9ytWmi2/VlZr 2sPY+SMgaHpXyYtBgzOv6EBbuaT+nBhyXIpNb8rF2MdRtbq90T3MFmP87Ozm9je9WMey T73Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DYJfwSbNbNYkkpU+3sFtsMMyFaJy1vfV0+WFGonwj94=; b=0AHxK/a/wH+NEHil/oUYNayTdHp36228SOtvf2QLHyXNLANDXIwv53P/jF/0DG21NN nAZuqWLgZwGn9V6p3AVvGjDn1ocDVfaQ2v+zxQBJieorRIYl3EumbhAmFZWME2RiPsgx 7cU0UTNnpqMilQc2w+CE8tZMLuyBhrotXWhWCkf9yvpeg9+0X4hzfvqs/b2hdW7RiXlv XZfSOhVSUfa9CLDZG5JvszrJKVwVLETcAQzS8QNC3fSn2I4CjdBOJtsB3KGCuRjpLMh2 C843ysD52+Epuc4vfh/qLPEcAByvJJVvyB+s80QQQFU5QL/6mc2PT1fkrmpEnAMDPoql Th/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="avL5xw/I"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 193si3161141pfv.108.2019.04.18.11.29.53; Thu, 18 Apr 2019 11:30:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="avL5xw/I"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390825AbfDRSCv (ORCPT + 99 others); Thu, 18 Apr 2019 14:02:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:59062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390809AbfDRSCs (ORCPT ); Thu, 18 Apr 2019 14:02:48 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3DEE3218A6; Thu, 18 Apr 2019 18:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610567; bh=10dkV9/VH2wk2rg6HZsI4y5IdMCsOLCKIBYHH0Pm4yM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=avL5xw/IzEC30AjGc1lI8iUGy6izeJueB41zg26mcVLrEw7OPfPXRiRUqkAdWQDP5 JJSDIEcUXzW6miiXu+WGZgXqK+gTxlXjmBV2PjkFUoUDlUjhJ5yRVQGtLoG/kyIzDL lH05FtvNeLX8RrpCI6DFzpiakZUnCii5Kdg+3puE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Herbert Xu , Sasha Levin Subject: [PATCH 4.19 086/110] crypto: sha512/arm - fix crash bug in Thumb2 build Date: Thu, 18 Apr 2019 19:57:15 +0200 Message-Id: <20190418160446.184994171@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160437.484158340@linuxfoundation.org> References: <20190418160437.484158340@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit c64316502008064c158fa40cc250665e461b0f2a ] The SHA512 code we adopted from the OpenSSL project uses a rather peculiar way to take the address of the round constant table: it takes the address of the sha256_block_data_order() routine, and substracts a constant known quantity to arrive at the base of the table, which is emitted by the same assembler code right before the routine's entry point. However, recent versions of binutils have helpfully changed the behavior of references emitted via an ADR instruction when running in Thumb2 mode: it now takes the Thumb execution mode bit into account, which is bit 0 af the address. This means the produced table address also has bit 0 set, and so we end up with an address value pointing 1 byte past the start of the table, which results in crashes such as Unable to handle kernel paging request at virtual address bf825000 pgd = 42f44b11 [bf825000] *pgd=80000040206003, *pmd=5f1bd003, *pte=00000000 Internal error: Oops: 207 [#1] PREEMPT SMP THUMB2 Modules linked in: sha256_arm(+) sha1_arm_ce sha1_arm ... CPU: 7 PID: 396 Comm: cryptomgr_test Not tainted 5.0.0-rc6+ #144 Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 PC is at sha256_block_data_order+0xaaa/0xb30 [sha256_arm] LR is at __this_module+0x17fd/0xffffe800 [sha256_arm] pc : [] lr : [] psr: 800b0033 sp : ebc8bbe8 ip : faaabe1c fp : 2fdd3433 r10: 4c5f1692 r9 : e43037df r8 : b04b0a5a r7 : c369d722 r6 : 39c3693e r5 : 7a013189 r4 : 1580d26b r3 : 8762a9b0 r2 : eea9c2cd r1 : 3e9ab536 r0 : 1dea4ae7 Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA Thumb Segment user Control: 70c5383d Table: 6b8467c0 DAC: dbadc0de Process cryptomgr_test (pid: 396, stack limit = 0x69e1fe23) Stack: (0xebc8bbe8 to 0xebc8c000) ... unwind: Unknown symbol address bf820bca unwind: Index not found bf820bca Code: 441a ea80 40f9 440a (f85e) 3b04 ---[ end trace e560cce92700ef8a ]--- Given that this affects older kernels as well, in case they are built with a recent toolchain, apply a minimal backportable fix, which is to emit another non-code label at the start of the routine, and reference that instead. (This is similar to the current upstream state of this file in OpenSSL) Signed-off-by: Ard Biesheuvel Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- arch/arm/crypto/sha512-armv4.pl | 3 ++- arch/arm/crypto/sha512-core.S_shipped | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/crypto/sha512-armv4.pl b/arch/arm/crypto/sha512-armv4.pl index fb5d15048c0b..788c17b56ecc 100644 --- a/arch/arm/crypto/sha512-armv4.pl +++ b/arch/arm/crypto/sha512-armv4.pl @@ -274,10 +274,11 @@ WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817) .global sha512_block_data_order .type sha512_block_data_order,%function sha512_block_data_order: +.Lsha512_block_data_order: #if __ARM_ARCH__<7 sub r3,pc,#8 @ sha512_block_data_order #else - adr r3,sha512_block_data_order + adr r3,.Lsha512_block_data_order #endif #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) ldr r12,.LOPENSSL_armcap diff --git a/arch/arm/crypto/sha512-core.S_shipped b/arch/arm/crypto/sha512-core.S_shipped index b1c334a49cda..710ea309769e 100644 --- a/arch/arm/crypto/sha512-core.S_shipped +++ b/arch/arm/crypto/sha512-core.S_shipped @@ -141,10 +141,11 @@ WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817) .global sha512_block_data_order .type sha512_block_data_order,%function sha512_block_data_order: +.Lsha512_block_data_order: #if __ARM_ARCH__<7 sub r3,pc,#8 @ sha512_block_data_order #else - adr r3,sha512_block_data_order + adr r3,.Lsha512_block_data_order #endif #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) ldr r12,.LOPENSSL_armcap -- 2.19.1