From patchwork Thu Dec 19 18:32:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 182170 Delivered-To: patch@linaro.org Received: by 2002:a92:d0a:0:0:0:0:0 with SMTP id 10csp861624iln; Thu, 19 Dec 2019 10:46:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwNbMXViaTXrfaAJVZXO6FLA891/jP6/yEfI+S+KKoZ4XnXncAZrBG+AzWC17EB/dklxkKT X-Received: by 2002:a9d:6211:: with SMTP id g17mr7852921otj.168.1576781207132; Thu, 19 Dec 2019 10:46:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576781207; cv=none; d=google.com; s=arc-20160816; b=jMVwMjS/BtIp22STJV9oWP5MGrluUZzjWjYSE5xTi+nqVq1sDpj3B3KZnv1crsH8YA BljXqoh6jEMHWQ8ZV3GM+Qv9phL0TVOJj8qa6179RNxV1UCaqnko8KtaUYc43cob9VGl EW0/g32pt//Oy+G4RJ8qFO4TaJBnPp83z6He4/kUdFAS0shmzcegDDYCmelZolTwCwli onVnYyEcbyk7hFVlPwFjmKkd0YYSGD4xGimsZ64hwj3v33ZBiRYmfSMF496dXs6WlQdN NuiwWKCqALH8Rj2j++iFqq5OO9X0Rr/NqCc9c2XTqJyOQziB2qrhAAktVg1XJesm0zIs 214A== 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=A6FYs/Ka0SbJ486xj+Er9mSWSAYR/oIOCQaKBPp/qts=; b=Kj8kxCV5yBSzR52zqaufr23r1Rrd8Z22Oory4gOf+EI96ZPiQfxcyFhBXcQVQ6pL3A B1YFzGd+UlXi3/TnqA4Lsq06sW9gik5Q961PPCcm2MN1NOpaM2GRuDvpK87U4uaYnqxv mCagKed9pgXE2etxfkUhJjUdevdbtb70p2mXw+ufP3NR+Eyi0a5a0ewdrbt8IHirnfLF VPALKWlD4h+B5k1udJ6zwEq7n75j8OzV9bnOvEYidp38rN6qs8VCYrkQbLL9CcX0Hl2Q eahtFgVy3DaGerMicgKwcvzkVsekpdKw0FFGyNjheWeWqMAYnGeys8nIX6LPRsgAmOot Gmwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GnQ/pz/j"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 46si3662283otu.45.2019.12.19.10.46.46; Thu, 19 Dec 2019 10:46:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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="GnQ/pz/j"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729095AbfLSSqq (ORCPT + 14 others); Thu, 19 Dec 2019 13:46:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:39496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729371AbfLSSqo (ORCPT ); Thu, 19 Dec 2019 13:46: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 D0109222C2; Thu, 19 Dec 2019 18:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781204; bh=XQ8ixBV1OwmvAx4bXVDtEJXlvNN41KaE6IvDZ7Ew5Rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GnQ/pz/jCCC/BvTST1tkD1+hcfm+4cbio+3OhvDq478i2Pvhr6hk/DpNNWMltVAWZ umuAdqwBlg4T3p6yT/UpqKsMyU4wKsOa2R6yXL+6G2qbeR9kZW5gfDqv61xu9Mr1KI JfydZ6pM3qEzuVxgt7DNgHnIZvJuKJNTsJW6VpLY= 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.9 088/199] crypto: ecdh - fix big endian bug in ECC library Date: Thu, 19 Dec 2019 19:32:50 +0100 Message-Id: <20191219183219.809163370@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183214.629503389@linuxfoundation.org> References: <20191219183214.629503389@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -897,10 +897,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]); } int ecc_is_key_valid(unsigned int curve_id, unsigned int ndigits,