Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp549315pxb; Thu, 19 Nov 2020 07:55:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyi97Iwf0RHOWr5TGjb5ShViyC5jxMhPwnHZ0NC+pq/FzMmaWkn33DPNZyWOGok4bX/RIYl X-Received: by 2002:a17:906:52d5:: with SMTP id w21mr27717498ejn.464.1605801318127; Thu, 19 Nov 2020 07:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605801318; cv=none; d=google.com; s=arc-20160816; b=vKhWIxdfxgtU/86sWg2Yc32GskGI27nMrpe1lPebVu5A0IdPSZX79w5l1J4SkrwmJl udFgK2nYOlssfalHFpRwnBuAOo7ACh8PHxtX0MSg8siNbUFkP4xMy36tqdHlrOlenMVx I5XQ7du7K7iAHQDrnAWDK9SBshSkoYosfetqU7gq4/GEIoD0VJLr/BO66ufVpUr3WTI8 EfClUyv0aqVSHTB6xHwaPZea9PUvqvfCrQ1fmAl2hGvFUqSlX2Ig5oIocfFo9+dArEpk Knrp7AL7dfPFiQ/KoNu7USSRXtr6ZMAye+xPDFbqM7c0GRUxFdwqqdm0bQPYxXN37WB3 AfLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B4eYZ8BtJ+Xv96s0vkBJN4bKwPI1mGpKSPj/atTPTao=; b=BG+XVw5q7BZHGp6MqGdYipkd3OdMfiX2NQhz65ZU/OAv/81BP91YGTcB7Goo4G9bA9 V7cSALsSpL4Ce0W6aMJ2oArd0W5/aUbEkeso6of6ucjHB4LnSPQsJ7vm6ty/FJqFSqsQ GNL6U0KY6ei7Q1kLVElVjGslTh48dY1kefFKnP5Ai3+fY0ktFFL0dbPOPoHFfRRz0FNy X4UEFCTgXclLyrPJd1GkYNZY9ARSmA0rhMF5gOtMMI6UPsC9c4wLbdkNzZFvkKFn/0NK Egl8y1F9pYyCeJxDCEAMDkA1y2x9l3fqWkOnL575vi9a80vT3ZyCPZoMeQMkTXTKbGE0 j+xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X2CLndD6; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hb20si35565ejc.664.2020.11.19.07.54.54; Thu, 19 Nov 2020 07:55:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X2CLndD6; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727435AbgKSPwx (ORCPT + 99 others); Thu, 19 Nov 2020 10:52:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728924AbgKSPwl (ORCPT ); Thu, 19 Nov 2020 10:52:41 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 312F8C0613CF for ; Thu, 19 Nov 2020 07:52:41 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id d28so5720287qka.11 for ; Thu, 19 Nov 2020 07:52:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B4eYZ8BtJ+Xv96s0vkBJN4bKwPI1mGpKSPj/atTPTao=; b=X2CLndD6x4dO4Y8ww/vjWOI2kjcDiGOnEue+rJYwfeW/8WYoST1Vap22OCgDFC3xjg IzQAsiROeT7WX47nc/cJida59ADdsovdlPvUj+nBmphV6LEUEVBb5pGMTKrT3zE/q4uR F/ht3F6Aw7D8dryDdAVxYpwP6Zkvf680g47LLROF/o/o0stekOh0OZp5i0ebMRzmhKc7 jbdQBNTkYsUAtf5HT5mvOmhJMR27P771vcfiGXagX0YZATIeHO4Z60vxO8rGV1/ccYvK qj6I1MCoBohQrYd1JzslnVrT0p7g+UPcZ74j5ag3oiGTQXUzfQpRzHeqfgIxAcSLICff hdPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B4eYZ8BtJ+Xv96s0vkBJN4bKwPI1mGpKSPj/atTPTao=; b=bMQtB9tCATrEHeW5kSY0eCGR4WxrzBUuOrRkE9WUwe9YZj0A9HBwWjZ9hRTgCGJuDC /0AAEMmvlDO6kJA0Cf603EH/yH0TvLa4yqsLosbV++pJYpCjVGMhHxayLkTWp/O9aDrv p3YpIjgrqJb5MbYkEi//bIzssSWljflKIPk8jUirrwikPHqwNMaYfpklyyGZqSNefG+y lpLIDPxknhQbduac/bRR5E2/OJlxDcYZ5CmqtmqeyeNlDA+QIsrj7EtETs5IwjjTo8va cfgjiJKSf0OSD/gH1sZHwSUco8AwOisLaJSBnczxt4wtEJvl8Hdg8DQCFa9YHzxWmOLx 4iPw== X-Gm-Message-State: AOAM5325B8mVbqzOmCrCjrgHU98VZ4K60KPRRt8PH8xJfJ2nqPI3yRuH S9Kghvd7jEbxCJHqADYR4Pv4MQ== X-Received: by 2002:a05:620a:5f6:: with SMTP id z22mr11361053qkg.211.1605801160386; Thu, 19 Nov 2020 07:52:40 -0800 (PST) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id g70sm127290qke.8.2020.11.19.07.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 07:52:39 -0800 (PST) From: Thara Gopinath To: agross@kernel.org, bjorn.andersson@linaro.org, herbert@gondor.apana.org.au, davem@davemloft.net, robh+dt@kernel.org, sboyd@kernel.org, mturquette@baylibre.com Cc: linux-arm-msm@vger.kernel.org, linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Subject: [Patch v2 4/6] drivers: crypto: qce: Fix SHA result buffer corruption issues. Date: Thu, 19 Nov 2020 10:52:31 -0500 Message-Id: <20201119155233.3974286-5-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201119155233.3974286-1-thara.gopinath@linaro.org> References: <20201119155233.3974286-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Partial hash was being copied into the final result buffer without the entire message block processed. Depending on how the end user processes this result buffer, errors vary from result buffer corruption to result buffer poisoing. Fix this issue by ensuring that only the final hash value is copied into the result buffer. Reviewed-by: Bjorn Andersson Signed-off-by: Thara Gopinath --- drivers/crypto/qce/sha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 87be96a0b0bb..61c418c12345 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -48,7 +48,7 @@ static void qce_ahash_done(void *data) dma_unmap_sg(qce->dev, &rctx->result_sg, 1, DMA_FROM_DEVICE); memcpy(rctx->digest, result->auth_iv, digestsize); - if (req->result) + if (req->result && rctx->last_blk) memcpy(req->result, result->auth_iv, digestsize); rctx->byte_count[0] = cpu_to_be32(result->auth_byte_count[0]); -- 2.25.1