Received: by 10.223.176.5 with SMTP id f5csp997699wra; Fri, 2 Feb 2018 09:27:13 -0800 (PST) X-Google-Smtp-Source: AH8x226TjJAG3EsteYdiElsk7crjtHduRlP+GtKihrZ+W4WgO58YWnlhMnxI5JccC1wSW7tCbUkj X-Received: by 2002:a17:902:3225:: with SMTP id y34-v6mr35308394plb.399.1517592433417; Fri, 02 Feb 2018 09:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592433; cv=none; d=google.com; s=arc-20160816; b=TFTRidn4XsYM/irbcA2ekQRVjkPBTKy5BE0whHmlQHCKDujEoRCRn9rXQCHY+1AOiJ K3E4FGdGCrTAd05g7UwMsVRD8JJO4TwTPkYAdZUx3UNJW6C76XIi6skaaeHXUHkzQ2Lx pKqB/T3rXKbZR4qUZme9YShl5c5QSDsK09Rp5TrEiUyA7SciLXIH+qyryN7SDiAbfPUB P4dNkFOlselufOc08kJ7Vb0LknlSOGXP6tYnAV0vhAYNA5jxaBAQRGGhX00JC20ryW4w uxc+20agft+Rqhlthj8mRMoz2G8z/r+s+/JZxbc8DrFVV+wsDmZ2p+kMZHZK8t9S+8bj JEgw== 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=60Gl1wpjZBVzvL8DV1XYMrp9GLWn0ORpD9toGSfpu1E=; b=WbKf1yovanWQLHu6+CBK89qDhjyC7CAwiXiUzsQO6X9ejvEy6CVvqaCjtH+8JlF5sY w17RXHIkhGaUJ+h7tWkCh/2AeEwYsjKWi/I/1sAXCIHEv7tJ57P/zRXYBzC0kn8l3ATQ +Rd3xEFq68z2QCqZa0v4hpLjmUkP/x38uJOGBkbs1hx0q9U0VrM489y9DbInu2R37JQE iMJvUvcHGuXaOm86DTsib+LYzDOSmQb2Vm1aZcxzZ7ikFoVnNQrO9Hqp4DkEPfoXTs4O s7MzuN3xMjBaTH1bh/RuFYTKCHH4r/mW8VmN1JB688wRgL7dOO2TsG5He37+/yk1OSVq LTuA== 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 v184si18595pgb.832.2018.02.02.09.26.58; Fri, 02 Feb 2018 09:27:13 -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 S1753944AbeBBRZT (ORCPT + 99 others); Fri, 2 Feb 2018 12:25:19 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40624 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753299AbeBBRO6 (ORCPT ); Fri, 2 Feb 2018 12:14:58 -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 6B7F8AD8; Fri, 2 Feb 2018 17:14:57 +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.15 14/55] crypto: sha3-generic - fixes for alignment and big endian operation Date: Fri, 2 Feb 2018 17:58:32 +0100 Message-Id: <20180202140827.482272510@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140826.117602411@linuxfoundation.org> References: <20180202140826.117602411@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.15-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);