From patchwork Mon Dec 16 17:47:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 181762 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp4621731och; Mon, 16 Dec 2019 09:58:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyJlicsFTI0PAg1HnVcoch3qihEsSU30QBXBrzdI3D2uVEQLAwwyzDXZQPtEdpf/kD837Gm X-Received: by 2002:aca:d7c6:: with SMTP id o189mr184820oig.130.1576519082942; Mon, 16 Dec 2019 09:58:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576519082; cv=none; d=google.com; s=arc-20160816; b=ujojVhXEaCVoYovGoHP9brA2+eTRaujI8XTLpTape77EHT8O0+GRjjHM5vkErAyYDE 6mqPEt/hajOjq6TMW82zWbo19EFJFYGkqKoRF6kc5ZGo/q2eSd25Tin+TdDHdWulwhVS mBiusfLnXoeQ+rRw+E9+6og1YWcy7A0Vf+A0KgNiST8+euDngqPuXMSj7GrQi/s4lkA9 qH1gVesZ4gs2UqRoWtmv1xrL6Bg7JxbumRY/snGcEPDLuv5kSNVCriYCSFpFlrylsWUB dH7YMhNRZHkV6PlZs/VcAZKpXo6dvqxZlBHVGQgZtAF+mQT1k26g74PPzZx1XowCnVFM J+zw== 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=dufytRRUoP2Di8qBDBleYPDEOzfOW07lKAXPqnQyLwA=; b=G5+gJL3UTyrs3UiD0TXfueHrx8FZU4I/BI+uGETDNVJD1ly54lzYrYm7deQN2JijNZ vWSRgF5wPH5EB9lCTio+H4riJzjlQTpX+Sksf7u8yjpHHfZ7/h+mB61t6VtlFn07N1mj wROCX7FAbmiQVpsmuWmCGTGMBt9nGSWYxO5R8DZM8NI5G9Vb6OkfgFTeP9783hI3Y0JJ sd8hXrzYXTdO7m42Ekv0o9mGswmKhd/ttt3zSpNTmKTwfDN7mQ1D5K9fuguINjckyJjD o+aknqtiWeS/8vWVkjrX9udxS+krjv2qpbzjQDExTaosxrAOJR084VlxHigIk1mWgeeY rNFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WHwyUURr; 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 x207si10274990oif.30.2019.12.16.09.58.02; Mon, 16 Dec 2019 09:58:02 -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=WHwyUURr; 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 S1728565AbfLPR6B (ORCPT + 27 others); Mon, 16 Dec 2019 12:58:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:57368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728549AbfLPR56 (ORCPT ); Mon, 16 Dec 2019 12:57:58 -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 ED18E205ED; Mon, 16 Dec 2019 17:57:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576519078; bh=2e8/UuLvJLNecZgC8ChFnpt7Ilo18ui9cPMWigdrHKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WHwyUURrJdSHNvH+nij4hUT84zieEIwCVNiS48B5zMh36TXXjIFq928SJ1Qr8CmgA nMl1ySgXR6+8UIPZ0GdGmc2axFVroS5+YzvmNWYp3NwJAGOI0aL1YXU5ex4mSH6uvE Y/x63fUzJ+iBp5RNDc/p+pDxAW1oeSZcJW56+ros= 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.14 146/267] crypto: ecdh - fix big endian bug in ECC library Date: Mon, 16 Dec 2019 18:47:52 +0100 Message-Id: <20191216174910.473333138@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174848.701533383@linuxfoundation.org> References: <20191216174848.701533383@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 @@ -898,10 +898,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,