From patchwork Wed Dec 11 15:06:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 181250 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp921509och; Wed, 11 Dec 2019 07:26:51 -0800 (PST) X-Google-Smtp-Source: APXvYqzoajNGOGb0gsMZZ3Ws/8iEbcQCLv12R2o3r3pSat03xIT0L71I59pfNKY0MyCc+D7YRyhV X-Received: by 2002:a05:6808:6c5:: with SMTP id m5mr3060598oih.143.1576078011736; Wed, 11 Dec 2019 07:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576078011; cv=none; d=google.com; s=arc-20160816; b=RPx8oO3h3Qpn6JL+VLQcGTSvVelWsWwAd6GtaO4gzkTkpDIKyiMiSVaTdSXzDXhpY8 4//2DQ90nu4pRz6wL8Avozju8W4DuNrf/J/8z1psAASAlwBTGK+T6VOYeJjcKWf1FZh/ A/FLdCXQ1d4OK3I/JbGF7mGDdaF7BqTdT84qR+m8zbhdiGLyeR5l8uKvwts2Jar0NuEb rvZWmxCBcuClVE9eK0YnscmZq1x95GwrAk62pG08qD8F7MygYsR/lFmngMFSTYTTQK5d Xpes8w4fSnm3e5Mdx8cVIzsWkNtdp08ny4ORCahdNXGoKPUMKoIPPm2Qr4XmrMwwmp3E 2y0w== 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=K9pIKlHTohhm2Nax2cnkLrnS6CYuVBJU4hKE8n03FTE=; b=xhQ5UMuGD/y6Rt7QS4XOYLquoVp+IL/tgROyijdEZQO/tVuzv5ZbDElbTadfniMsEL 8WgrS9aGqPBgX2mx6eHjeqsruH4e9RA39n3e9ZFZMHADqUsFQ3nd972Qytgqyir0IliR bu2f2Senb8XdzYfwZSPuO8qvOkFchbk8G0F8q0+jCCaSU1TXs15YEP1VoObTEsl2dXJ4 NfeKdLH3OoMVBRPF2E95So1NWQgueoqHBP34NuJ4sAST/5gxeus907wmPQCg6R1bysrN LYzkcCt3Mv7tNerAwOIwGpI3J9Rl8dBwSgk2HeG16Z5ziF7HwxTAgX26zT9HoWC8inPY Qn6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b4YT1Qk7; 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 z25si1303201oto.211.2019.12.11.07.26.48; Wed, 11 Dec 2019 07:26:51 -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=b4YT1Qk7; 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 S1732991AbfLKP03 (ORCPT + 27 others); Wed, 11 Dec 2019 10:26:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:59776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732983AbfLKP00 (ORCPT ); Wed, 11 Dec 2019 10:26:26 -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 C895E208C3; Wed, 11 Dec 2019 15:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077986; bh=bxchu0qrYflqAmDF3wnDWrczTqaHYpynd2lndRqnIO8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b4YT1Qk7gbUndX5Id9+xBPlhmRYT49nTECXPvUmBO99XmSrNc2+1EjTHTWm0q+apB V0UJpW6DhmrIsH6QzMmFjxTO6oITPWMJChzvmXatCruzjHyq4nus+y7/wJzgMYJtZ8 RWjyGD+HhE6bxDBCzO1XRfu8LVmqYm7oo0P+x/zs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Herbert Xu Subject: [PATCH 4.19 233/243] crypto: ecdh - fix big endian bug in ECC library Date: Wed, 11 Dec 2019 16:06:35 +0100 Message-Id: <20191211150355.060433734@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150339.185439726@linuxfoundation.org> References: <20191211150339.185439726@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 @@ -906,10 +906,11 @@ static void ecc_point_mult(struct ecc_po 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,