From patchwork Wed Dec 11 15:06:19 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: 181233 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp908051och; Wed, 11 Dec 2019 07:15:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwH/CkK+KSF/rUPSlhBC6pv3y2q1WxCmP/UHmKzxUseEcUN6VP5Nj1s53fZd5uWm7Ep3JW7 X-Received: by 2002:aca:edd5:: with SMTP id l204mr3283252oih.98.1576077355727; Wed, 11 Dec 2019 07:15:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576077355; cv=none; d=google.com; s=arc-20160816; b=eNImB8yQ5wxz5eXxDSi0AcUn6Il7hOQysfyBGre+nxOhF9l/rAzjJARLt58XYw84t8 m8mDaPC7oORSpvTNmc3xuVz/ZyV+mhtyN8m4Nu6i3HGLvzf1ztkLihzLeLRRMiXL2Naz 8LcEf4Lx9CDeiASBv6RlSCkyLjavKCrFFYlu8q4xpIgFOoDp0mloMl6m8Dh5OTuqfCJC 0/Q8dJPJX+LNGX+/MddmUwIT62AP+3NJ3Ij69wBn5H8GTgCyYagtWOYzoYIz/hY5kLzE W9oYcH0+qHOXPuPTn73ObWsLLJp493ThB7mflfB/shKvOWByR8bjW8nakrjeqGnTMAgP FfVA== 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 t28si1275776otr.16.2019.12.11.07.15.55; Wed, 11 Dec 2019 07:15:55 -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 S1731308AbfLKPPy (ORCPT + 27 others); Wed, 11 Dec 2019 10:15:54 -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 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,