From patchwork Thu Nov 19 15:52:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 328428 Delivered-To: patch@linaro.org Received: by 2002:a17:907:2110:0:0:0:0 with SMTP id qn16csp471671ejb; Thu, 19 Nov 2020 07:54:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZDsbYPSG9SPegC5+BqP5A6MAMFomhVePyBHCkM3+swFPJ5nJtcBD2h57st+lSbSryoR5z X-Received: by 2002:a17:906:66c9:: with SMTP id k9mr30332924ejp.204.1605801250577; Thu, 19 Nov 2020 07:54:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605801250; cv=none; d=google.com; s=arc-20160816; b=lamEuxI+0dMCgFOhkFSOlyRILdrnqZnQc5DG16FXrLjx3ITcnPsO2zwqR776PqFZ+T VVPQfz30OhDOxPEy0J6A2B2jVQhyjRAPtit7GYFwaz7RzAotFaU+CEBchtEy5Mnh2ln5 Yt8ZRD531DHOIo3REQHB/lcWHoCCWqPdwcpRDgOtnGMiGESpKDV8FxJZofEXVqWMgH5A 06geOTVDo0dN19yn9zKuTMDC2UBZVTfL6Ji/ofPGyOlmgygDNa2X7L027otzGYm77YJs sOkfbQ8qVAH/vZw4vmTUAVus4d85ympEfO/Ew5SxjogNKIEEHg+yUaDw7L8ENP90IlFc i2dg== 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=oVtllviZZzr1kIbhP53Gw7ZpP4JGQnPSZn5HjmOmKs2tlGUvxfh9CU+uugaB61MzFN riLxf7Ab3mclCzmsgdf/vPzeDi4IP4+rhg4lDVGUn62XcruT/HDuE5b7yd9nTOXEYo9x /LEzbxZN9r75TFBp9WRD5dngdgXZaj1mJZ/6iKhJeelWq5dPFZ7z5PdqLu/eb20wazQ/ K5vuUgrDGfYidgX9ElQaFtAbo8hIpYrnRkmR4oP/OIVU9iZMFCAXl+YQMxbmf7oGiF1o iQPE1NyVyO28MR4LNV+Oxzg4M4M5CuCVv1T03efJNTvhH+fmQ5Z0xQBhW0hUR5b5e4jp o+pg== 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 devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 ok23si67063ejb.243.2020.11.19.07.54.10; Thu, 19 Nov 2020 07:54:10 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-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 devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S1728933AbgKSPwm (ORCPT + 6 others); Thu, 19 Nov 2020 10:52:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728925AbgKSPwl (ORCPT ); Thu, 19 Nov 2020 10:52:41 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33848C0617A7 for ; Thu, 19 Nov 2020 07:52:41 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id q22so5775281qkq.6 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=XWb7zZ+Qj9lGNyeBcV04RiOGszBiDe+id0msetIVqeRHLN0sgSHoZFx6UGdHIGvDi+ gEO8dENwMOKBWGq3LmmhpLoaLl1F9ktqKXnFoxSs/j7eSNY5ZvSLrdgH0gVhS83/mAau 1CWKESI6+j+Y06LFF3aIe6OKpX3DQA34FAVNNkv1LnpBowhRDfCD8pVxmISXxCIvdvSG pPyWKCKcy2cXeTWvKfs7WVrhMxTL94Mq/KSoC2iz5vzhiN0uOJ9aLcg9b+/Ga/14nAcL lnmhORmsBlvYOpal0vOZwu0qRe+PgIqELIdzEh6sbk0gDC537pOVDvFjZYn563D7I2pB xwsA== X-Gm-Message-State: AOAM531b8q1k+fY0ym0IWVLOsBaTneVyMA+t0WOTqRJ2ia1RcP97Noau XdCNiALUX8vfav0XgiQXIiIYNA== 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 Precedence: bulk List-ID: X-Mailing-List: devicetree@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(-) -- 2.25.1 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]);