Received: by 10.223.176.5 with SMTP id f5csp976623wra; Fri, 2 Feb 2018 09:08:19 -0800 (PST) X-Google-Smtp-Source: AH8x225npxzXoJcI5Av6uO67f9evFfW4aE+b3oHMH2tUB6ujEEdFOmjeHBPzotUbG8Kg4EMNVHs4 X-Received: by 2002:a17:902:b605:: with SMTP id b5-v6mr15583530pls.318.1517591299140; Fri, 02 Feb 2018 09:08:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517591299; cv=none; d=google.com; s=arc-20160816; b=BNj+14L6zVXSa+ECVJrsiaRKNgJZ4nVyTi/2GMhsbNBc4+bF1tlpvbYxJBT+s6a8mh J31O42sbB707wfxfh5ooRoChQXQ4mojOsx7emYRCIGJPZZngQZm162HevctbjKXxyd7E Nqlm7z40cZMReo+RnU+37IeAjcHDcANnaUEtuVCySgVwf7xt2faSfL5fAr5glS3lBB2R XR5fFvGy0XLjDUfs3lYjS0SpErnuO0++8Kq8vLcK+jbA/QkIpmWYEh1ZveMo1lgoA/Vp kGlviKvmIEdzMnEEAVHHMnKFqK8gKOhWWd0CRMYcibIUyCU9rDyDWRk6QUJkEkO36Bnu BEmA== 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=t5Sw6QyrZ8R4c0fG3iPf+wYj4/1m15lhn5f3MqhwBAw=; b=KR+vcWvdkuHkhiG0oRxwvNb3BF2jax9grVbUZmfcnMka8RsmBBK1FTjX1mSLzeV7DQ 6jSqi7JgCYbzh1V8YlvVcsXEYHPBUJzCbguIK1/COlkpsqLmWcNHfF5nQ2JnjOPGjYhA t03NGM8npQD5pCfKG+Bf5qanHhxjFNVkQ4hUCSvjXn+f8JMP3LvSKm7HXZfFIuiQMzWa MTZf5XPSn1YgmNra8F4G760gqpsD/ZDFTEkA82AIH20qD/Cf6dq24CSFDyGADe+8c5AW +OKOkwrcK0wlsj3YSREKRzaCTeFXCFGDa/Iby3h5Y+2fbol7loLRvZ/dDGqfiEaQzIuL 9/6A== 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 o15si1708188pgc.48.2018.02.02.09.08.00; Fri, 02 Feb 2018 09:08:19 -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 S1753048AbeBBRGI (ORCPT + 99 others); Fri, 2 Feb 2018 12:06:08 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35670 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752657AbeBBRDU (ORCPT ); Fri, 2 Feb 2018 12:03:20 -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 CE709EC4; Fri, 2 Feb 2018 17:03:18 +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.9 09/86] crypto: sha3-generic - fixes for alignment and big endian operation Date: Fri, 2 Feb 2018 17:57:29 +0100 Message-Id: <20180202140823.645916199@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140822.679101338@linuxfoundation.org> References: <20180202140822.679101338@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.9-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);