Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3903875ybi; Mon, 29 Jul 2019 15:02:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBo+XUWExyenCh6xSln7aw4ZERyoz7SLrcFRMwA4J15SZXluiZs8MiFSzRNEtUTb07bYiQ X-Received: by 2002:aa7:9f1c:: with SMTP id g28mr38205691pfr.81.1564437750138; Mon, 29 Jul 2019 15:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564437750; cv=none; d=google.com; s=arc-20160816; b=LIuCD56RxxgYKflejOeqxqr3g3VtJPNCzabIQ96iO/ReX0lWxw1noerSwsA0gKIZzZ bWA/FeH45BxBt85jEagtiGfM2Ll4F0EZfYzLXzMIUFJIRJNhD7CtPGpak20H1Nl74UGV rBzMoRBXW0oppxydJP4tcldxciuTtTpvhQoZhQiRhETn6hbgVl8eqTqkXhRBVq6thbcu g027HDz6dSQCyksD2jrZ4mlm0UIulq/zSkOOYVVuRgInAP8RUyQOzOW9MBQmbn1XNkl5 Sw/AFGWP/1WpCzLVNKWusH2JzHenIZI7HAipED1Espe4edb1cT5eoM2em4jg0Uut3Bkd Z3nA== 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=pdJ5KUgTa5sNCSmu8jFIuB9TxXbNcfLVY3kX970jhTs=; b=xY3cuCQKJTTucajxlcqb6d6vke8JQlLA4nu04XiVsX4Ec+QCYe+3nPWypSaNrwmvEV bZ/FMv/uSl7loo5ip48L9zoeSgaSEcNySm8lvwHh3B7jg3YEnDfpUjK+bMZUpPHT78QQ 5FDgIRsRHrpfzgWDCZ0svvswuRSpy2lFZQhbraHIi33gD/Q6BQu7h6uOyHslfLAcZjAH 5OdOc1LwlVhsdVxeDpy5lM47UcSj7LKUZ9c3L6RAHnvAivVYWtdvQGDVEtuYRCLlT3Ep icvUBHnpo+eleOf047gO7QPcd5t4AfxylIU2q6+La+mfQK6VKAoPA59xNAWfgt9qPPP/ siCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JNRoRsmq; 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 bh8si25528251plb.175.2019.07.29.15.02.15; Mon, 29 Jul 2019 15:02:30 -0700 (PDT) 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=JNRoRsmq; 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 S1730107AbfG2T3s (ORCPT + 99 others); Mon, 29 Jul 2019 15:29:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:42398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728828AbfG2T3o (ORCPT ); Mon, 29 Jul 2019 15:29:44 -0400 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 173A22070B; Mon, 29 Jul 2019 19:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428583; bh=YeaONwwOYtzz3Ca9+yCTMwQL28bim9Ud+LLFomi6VwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JNRoRsmqXIR1TrFjP5wkjfx6FwRvbE24obLqHenxhB1B0jzB+mFR7n9mWabRPR/+a ZP747MQvotJdnWysIGn9GAvLr21K+uBmFNQLB39E/WzxN1YXKjNlLJ+oIgSzQKOz2U KPXX1uS4dYGiithb+Zm0Dr49jKExvG1SsUZ5d170= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Elena Petrova , Ard Biesheuvel , Herbert Xu Subject: [PATCH 4.14 122/293] crypto: arm64/sha2-ce - correct digest for empty data in finup Date: Mon, 29 Jul 2019 21:20:13 +0200 Message-Id: <20190729190833.942059019@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Elena Petrova commit 6bd934de1e393466b319d29c4427598fda096c57 upstream. The sha256-ce finup implementation for ARM64 produces wrong digest for empty input (len=0). Expected: the actual digest, result: initial value of SHA internal state. The error is in sha256_ce_finup: for empty data `finalize` will be 1, so the code is relying on sha2_ce_transform to make the final round. However, in sha256_base_do_update, the block function will not be called when len == 0. Fix it by setting finalize to 0 if data is empty. Fixes: 03802f6a80b3a ("crypto: arm64/sha2-ce - move SHA-224/256 ARMv8 implementation to base layer") Cc: stable@vger.kernel.org Signed-off-by: Elena Petrova Reviewed-by: Ard Biesheuvel Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- arch/arm64/crypto/sha2-ce-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/arm64/crypto/sha2-ce-glue.c +++ b/arch/arm64/crypto/sha2-ce-glue.c @@ -59,7 +59,7 @@ static int sha256_ce_finup(struct shash_ unsigned int len, u8 *out) { struct sha256_ce_state *sctx = shash_desc_ctx(desc); - bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE); + bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE) && len; if (!may_use_simd()) { if (len)