Received: by 10.223.176.5 with SMTP id f5csp1019520wra; Fri, 2 Feb 2018 09:49:03 -0800 (PST) X-Google-Smtp-Source: AH8x224GluDnc3js3n8bXKrg9MPnLfN5gmtlirH/R3vKbIQuBDuyc+OY+omkZ0MlhJc3YaWwWLjP X-Received: by 2002:a17:902:9686:: with SMTP id n6-v6mr35029640plp.333.1517593743409; Fri, 02 Feb 2018 09:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517593743; cv=none; d=google.com; s=arc-20160816; b=BCBj9QgUNsnb0zDZwjwQnWfuP2dTesAK0/lbXPBRKxgShGbXntXIxkMRVeqYGty33w yWkPvPO/T+eutG1kIAWrf2zGmHhyiQAaGyCSU6uZOS1VZODXAhcd3/1yNhvNmayFyUaz PtFDNFtbutIMXJNhWSTuLektifKcKY8+h8ioLw8DX6rHyeZaFiuZBwW1FX5L59wF202Z Wh0QwDPWQ12Y3lJvpX6dUj/a+k4MhponsXuYFd10RQiryLeSHq6Sl9SWGFooGIxPwddy RgLMas3WsrOQs2n4s4XM2KYFpwOmNy5HrvfjmlJU/3OWogOYrQjJDoXtuSvPJj/tmL+U ZdHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=YEa3+WElmybzeZpOkH+TwxR6WlfDp0DFkf7hIF40OZE=; b=g5nB+WTcf/RuB2HoIb7qEI3U9Is6FGYgEUJDSpX5X8pAQRv2mrXV1HbcfNbxoKG0TW sY62cziI9aiK2vdD8Ixx/DyNGTHFzTnHwGsJB0dzFANNV16zcj4QUv5MtV8A/OkZ2lfT pnRUZtgYkYR0LlwZsvmXNsY3+m09CizJsnbbP4n1U6BP1KoKY4XOOmVRT139GlBlq0Ml bJ78wGb+p7zVojHZJL8tgJdP0i8YW0VdJfoiLSvWW+BJDBW6IAuwfWY61upgl1/g12tE /n33XRepEYqzUlmHPscC7ePOAN0ytRB9zatXuGFqP0PwBz3cMKUixOKUO319QoTNmWs/ 8JYw== ARC-Authentication-Results: i=1; mx.google.com; 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 l19si171723pgc.166.2018.02.02.09.48.48; Fri, 02 Feb 2018 09:49:03 -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; 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 S1753558AbeBBROE (ORCPT + 99 others); Fri, 2 Feb 2018 12:14:04 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37078 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753156AbeBBRHg (ORCPT ); Fri, 2 Feb 2018 12:07:36 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 60148EF7; Fri, 2 Feb 2018 17:07:35 +0000 (UTC) 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 018/156] crypto: sha3-generic - fixes for alignment and big endian operation Date: Fri, 2 Feb 2018 17:56:39 +0100 Message-Id: <20180202140841.138315849@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ard Biesheuvel commit c013cee99d5a18aec8c71fee8f5f41369cd12595 upstream. Ensure that the input is byte swabbed before injecting it into the SHA3 transform. Use the get_unaligned() accessor for this so that we don't perform unaligned access inadvertently on architectures that do not support that. Fixes: 53964b9ee63b7075 ("crypto: sha3 - Add SHA-3 hash algorithm") Signed-off-by: Ard Biesheuvel Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/sha3_generic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/crypto/sha3_generic.c +++ b/crypto/sha3_generic.c @@ -18,6 +18,7 @@ #include #include #include +#include #define KECCAK_ROUNDS 24 @@ -149,7 +150,7 @@ static int sha3_update(struct shash_desc unsigned int i; for (i = 0; i < sctx->rsizw; i++) - sctx->st[i] ^= ((u64 *) src)[i]; + sctx->st[i] ^= get_unaligned_le64(src + 8 * i); keccakf(sctx->st); done += sctx->rsiz; @@ -174,7 +175,7 @@ static int sha3_final(struct shash_desc sctx->buf[sctx->rsiz - 1] |= 0x80; for (i = 0; i < sctx->rsizw; i++) - sctx->st[i] ^= ((u64 *) sctx->buf)[i]; + sctx->st[i] ^= get_unaligned_le64(sctx->buf + 8 * i); keccakf(sctx->st);