Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp816116ybl; Wed, 11 Dec 2019 07:57:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwdsOj68KHN5ZvDPMjZyCfJyb4NNKWFLilZ5rdc4AOEH5nZLgn1RoVvsZMBFLwmbzicDcA2 X-Received: by 2002:aca:520b:: with SMTP id g11mr3431646oib.167.1576079874015; Wed, 11 Dec 2019 07:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576079874; cv=none; d=google.com; s=arc-20160816; b=Qy4lgwvH0zGnXXlpS6Evd4u48AkK05MXwfnktVRMEhsx+TRHgNFiez31mSXa8tcEpK 9BzPy/MWkgu/r5xwRzcN28+6OTx3FrM0Otm9hi2cfu81bj2RM9Vx+HYPQnMHP6yQlHyI NU/liLT8SLPntQxdNGye+DXKfQdx7zDLA9d7cntf85+jMmYdtRyPvTPUtAPQ89xnZFTu vPcS7awOlBNv0XbMc0jfVB/Eeqm/GIAzq5wnHx+TWjp+0/B82ahBhtVpMdrt7oukF1WK jDIgByi1Wp/Drhf20CqXA4XW6WuMdF3T0/acd+1TmMD7pcHH9pkczF3Ilgk3bClHwoGT 1NMg== 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=G7tEDighGuGTYoGbJzukCyHB3eGHpQXk6NrJekV2W5q7/a1iAuXdoKqY8qZ6DG3GP+ M1H+jWw+O3CWsL4zN6g/mkZwKx6J3RnTDfehgHzF5G1HKb7MVn640QqByhWP0F8N4enq 0nZ+8rz5lMH8AQlURqZZ9pw8p1u/+LlhfKjC1HuQEO5QnSmH9Cxx85RKjSqYNCw5dlfP RkyHkbz9Xz6fJWDkPEQ/VaeuL+YSc85N70WYksgokliI6OdPb4F82R9A95GBCdEuZra2 yCwTl6utgDYEUE1/Ljpgfalh28vtaNoi1emSa5EPOKy/l2xjkit9aFbu5PQqNefOnKxd DZOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wSz8WYcQ; 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 e10si1131748oti.61.2019.12.11.07.57.42; Wed, 11 Dec 2019 07:57:53 -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=wSz8WYcQ; 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 S1731092AbfLKPPx (ORCPT + 99 others); Wed, 11 Dec 2019 10:15:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:42250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731568AbfLKPPo (ORCPT ); Wed, 11 Dec 2019 10:15:44 -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 E2E9824658; Wed, 11 Dec 2019 15:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077344; bh=wytKeplqK/AKhB4cIpXTYLqEbmNYTJ0B2BTWnB98EBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wSz8WYcQZc4wiaFJg5GP/j/ZC953qLA2fovNJFbHLckR6s1Vr15y4jScElseK3xnO PWi7kywf56whDVZn7RRFk1Z0zBy5a8kM+x3hO42rxN6nS8Ur7dqgfK25qBs8YzjEFB StXYNlc8KjrVUFRf0mD7WR5JkfXcVIfTnbF5FY20= 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.3 090/105] crypto: ecdh - fix big endian bug in ECC library Date: Wed, 11 Dec 2019 16:06:19 +0100 Message-Id: <20191211150300.743726216@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@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 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,