From patchwork Tue Nov 30 07:54:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Toromanoff X-Patchwork-Id: 12694104 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9282AC433F5 for ; Tue, 30 Nov 2021 07:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Dp1IPBlbga+TCkHiiXBPALLS8bsDWsUN3ZjB3ypzl1A=; b=X1Duu6uGYMFUsj hUrxjnmxwT2+LQZQVkJ+Va46Lnzez9YPKXdYnIrglu6Rwrhi2n581nS8sDgCP0yRAu7j+YN2cS1D2 dJqFv/s1jKEHMytBCY6wYiFZFas33zFEWO0GCmtfSVeMgElZ7MEJdKU5vbSgcf/8G96dvS5ZYWgKA BhoWdqxGWmaAcDW+3HMDFOsloUlDi4ZiO4fmHi0OvC+nLi7DoMiZZs/W0px3Kj8ILVZnUUW+XX9rc Bt+U0vVSbr4iNBnPsDWpaPkzheQCi7umIBG6M6CkNLeo0O02ePYQL6GSFAzLyoC3bNn0T9c9b2/zn C7njsQQ3P/Fy2Vh/D7Tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mry0Y-003zUC-NO; Tue, 30 Nov 2021 07:56:58 +0000 Received: from mx07-00178001.pphosted.com ([185.132.182.106]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrxzt-003zCJ-3b for linux-arm-kernel@lists.infradead.org; Tue, 30 Nov 2021 07:56:18 +0000 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AU6enp0000446; Tue, 30 Nov 2021 08:56:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=jnlLz6rG62r6hYxzi9VduP8Gn2LfSIuCGxtED1HFSDk=; b=2NFrouucZ2DBmMsqePwT3Kb49gNSK19E3D/B+P26zLtGzm8eUAxQYlIO5gasJRiOgQNB owtPf1WbfkwlM1xy8WfzN6E+Ei2JNNXp/tNdQDZ85WXTIgB5a0L5JflJHwmUcbPce+t+ jX65qvziP1F2ZhkNv9nbkYV6BEKVIGLGaj1Od61U8JrxXq72X+5Cr50SFwStJ6Unq5NB eUBcug0niMdjyMGZ5vQGfzxPqFFdkhFht1UE4rfHgJp93B7TPZSrCF3TtQMRfRsteNlR heKKjfh6XysxdkQ9zo7WGm70Mq4v5ZA5RNXfPN3IJEJ0pjsHV2yEU0iG9k3bs5rhtxh+ gA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3cnewbgdj3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 Nov 2021 08:56:05 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F102A10002A; Tue, 30 Nov 2021 08:56:04 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E8D9B21A222; Tue, 30 Nov 2021 08:56:04 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 30 Nov 2021 08:56:04 +0100 From: Nicolas Toromanoff To: Herbert Xu , "David S . Miller" , Maxime Coquelin , Alexandre Torgue CC: Marek Vasut , Nicolas Toromanoff , Ard Biesheuvel , , , , Subject: [PATCH v4 4/9] crypto: stm32/cryp - fix xts and race condition in crypto_engine requests Date: Tue, 30 Nov 2021 08:54:56 +0100 Message-ID: <20211130075501.21958-5-nicolas.toromanoff@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211130075501.21958-1-nicolas.toromanoff@foss.st.com> References: <20211130075501.21958-1-nicolas.toromanoff@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-30_06,2021-11-28_01,2020-04-07_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211129_235617_493324_D9DA636F X-CRM114-Status: GOOD ( 15.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Don't erase key: If key is erased before the crypto_finalize_.*_request() call, some pending process will run with a key={ 0 }. Moreover if the key is reset at end of request, it breaks xts chaining mode, as for last xts block (in case input len is not a multiple of block) a new AES request is started without calling again set_key(). Fixes: 9e054ec21ef8 ("crypto: stm32 - Support for STM32 CRYP crypto module") Signed-off-by: Nicolas Toromanoff --- drivers/crypto/stm32/stm32-cryp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c index ab4a107a0860..b2b553651964 100644 --- a/drivers/crypto/stm32/stm32-cryp.c +++ b/drivers/crypto/stm32/stm32-cryp.c @@ -674,8 +674,6 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err) else crypto_finalize_skcipher_request(cryp->engine, cryp->req, err); - - memset(cryp->ctx->key, 0, cryp->ctx->keylen); } static int stm32_cryp_cpu_start(struct stm32_cryp *cryp)