From patchwork Wed Dec 11 15:06:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 181227 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp659940ile; Wed, 11 Dec 2019 07:10:14 -0800 (PST) X-Google-Smtp-Source: APXvYqz57FxjvmPn+v3zn1Nj27YzBvmg1g+Re7tFRzB0WRBzj0df5A+TZdhT3gGD9HiHUYEns0vM X-Received: by 2002:aca:5588:: with SMTP id j130mr3057900oib.122.1576077014693; Wed, 11 Dec 2019 07:10:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576077014; cv=none; d=google.com; s=arc-20160816; b=TrK5UDaobmDxfoXN23CUHpta6k8bys5TILnfbVEtbL6ymz6peRTdM3Q/dHlB4JkBjb 1TeGu1c3TsIZkPJ6nox6FAULC89Fw+TffhAVAP4lrPjIypZj4ZuNg0yBHhng18Aj1siR bHXZjSjYKIsc7ZKm8gCM+wvth8lKIi5oTQBq68BZJwWnsqqH5kELqF+z9awAoVhiPoHu t1+GoIJJWwE3jf7BxmPqaymR6oDMkLCenZUPbVafbBjYWxZJsVNK2piFcdu1ShkMODyE FfTO3fvdR2CDvS+vVleRq3wH5xH3jjw4Qk3RVugJ1njP87Q+0O8tr/MudukRxr53kMJw Av4Q== 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=ZWt/Cs13Rs2/7EV+5e5/rbugaTGYl1TT/NK9jH4kh/Y=; b=IY4ENqjHjpgNsCVJgdVkUZHaisOj2su5906Iss6EEVWRilqckqHDGgxbjIIrPamjz5 patDAg+o857E4SaR4djwD2tTyQgK9XWhrR/ddeV+3B1ntKd3UvrDGk8tg8XOTNgoEEHq nEYpgqjMcd6x8fV310M2SYEiU7w4JpmfYQ3Adx3PCJSi7h54uZnY5d+RHKsdd7Fm65lr yPmGdjGj4innNiJJc8Di19Ow41PGgQEOdltoUQwfKAOhw8mjju8Ydug6AkXuLmsrqZO4 SR2wmm7ltnkVYdAc4LZQB/r+faSCWTCNI+gSddXa8lYSkwVCuCKWQl95Ycg/k4wJLLhO kc2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uY5bbTU7; 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 b18si1287476otl.202.2019.12.11.07.10.14; Wed, 11 Dec 2019 07:10:14 -0800 (PST) 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=uY5bbTU7; 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 S1730716AbfLKPKM (ORCPT + 27 others); Wed, 11 Dec 2019 10:10:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:58340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730700AbfLKPKJ (ORCPT ); Wed, 11 Dec 2019 10:10:09 -0500 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 6381F22B48; Wed, 11 Dec 2019 15:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077008; bh=wytKeplqK/AKhB4cIpXTYLqEbmNYTJ0B2BTWnB98EBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uY5bbTU7YC4c7zUYgF+8vtS3C4wEb4/XZdg1zZsy4M65WUtqeCixty0KGrefioE9E vy6fmlmzM4Y62SsPeQfsu6BtLU1io3PAQClIIk7b3rTNKars3pLFcHiN3MvVCutMcK 7UDc/2ZU0JysScYJc+/kecgGJ+HhB045IjhF5ScM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Herbert Xu Subject: [PATCH 5.4 73/92] crypto: ecdh - fix big endian bug in ECC library Date: Wed, 11 Dec 2019 16:06:04 +0100 Message-Id: <20191211150257.641511332@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.977775294@linuxfoundation.org> References: <20191211150221.977775294@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel commit f398243e9fd6a3a059c1ea7b380c40628dbf0c61 upstream. The elliptic curve arithmetic library used by the EC-DH KPP implementation assumes big endian byte order, and unconditionally reverses the byte and word order of multi-limb quantities. On big endian systems, the byte reordering is not necessary, while the word ordering needs to be retained. So replace the __swab64() invocation with a call to be64_to_cpu() which should do the right thing for both little and big endian builds. Fixes: 3c4b23901a0c ("crypto: ecdh - Add ECDH software support") Cc: # v4.9+ Signed-off-by: Ard Biesheuvel Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/ecc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/crypto/ecc.c +++ b/crypto/ecc.c @@ -1284,10 +1284,11 @@ EXPORT_SYMBOL(ecc_point_mult_shamir); static inline void ecc_swap_digits(const u64 *in, u64 *out, unsigned int ndigits) { + const __be64 *src = (__force __be64 *)in; int i; for (i = 0; i < ndigits; i++) - out[i] = __swab64(in[ndigits - 1 - i]); + out[i] = be64_to_cpu(src[ndigits - 1 - i]); } static int __ecc_is_key_valid(const struct ecc_curve *curve,