Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3592907pxb; Mon, 24 Jan 2022 13:03:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhohYNx5cCicvNJEFOZ1ZBCnfF3cdv44rhF0RcefcJyR1UDH3D9v8jigOCZaeyggtlXCXu X-Received: by 2002:a17:902:8695:b0:149:cb5d:ddf1 with SMTP id g21-20020a170902869500b00149cb5dddf1mr16481374plo.103.1643058206542; Mon, 24 Jan 2022 13:03:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643058206; cv=none; d=google.com; s=arc-20160816; b=F0d9NhlPMPm1rnanIIHSlm4pkwXEhrTbBfZzY+yWGY6KOddA2lSuwtUINROPuof+6d +TNVFrxITwWH0OrdutzTbjz8K71PAOuTNmTGWUk9hypUifrz1CUU51a7u4m8jcJ0AhXh e6TutZQubVAV3VwMVzVfjFKGoLA/3m0cmGGFiDaNpXP5vhoG0qbdQJcZjBMKktP6Rd2u 8iHa7OMQEqAlS51Gr2usj3KOQtsMDAl/wtUgfl83YalQU8myKG7sGEUqvNjFEbbsS40W UfSchM3V/PsVgThJIlYWO1YArrPS8EokVXch54GKtMAZphPLwsYkkgzTFOptqgawrnup uVnQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RUjYeLPu1FHMYS2N70SU1ysSNEIX4WCesew3TBSxvvQ=; b=i0xWGMlTidTPLHeKvgo5zX3pQUF87irHUm3YMZeO5ywZAprxKQsPI7Gq+/65j9p3u/ UxwsSeBfrx0NLDiZWLqCOXfWSgLgeRsRc0jhUDFvOZTJXqnj1XN3mLAZp4Ph6QMEUTf6 KQsnUdbhGkaPnxYQHc5jazTiv3FrnZ5A/0QCUfeq83aa1dPTfAsbm5BGs3DDzFAzMPYe xXYcxtD8cvqCdEMx9As5vazBcebOSD5Ywg6Rry08SogGGm7iVDA97E3P0aXbnGxyz7R8 Q+OKfuOy1PvzXHJ6NmcAatDrarOOkqvBqiDxCyu4EDIyrG192NlWDEkhfAgaCFL808c7 HnqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=R9tSQkDe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si356109pjz.179.2022.01.24.13.03.11; Mon, 24 Jan 2022 13:03:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=R9tSQkDe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382916AbiAXU0a (ORCPT + 99 others); Mon, 24 Jan 2022 15:26:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359709AbiAXUAE (ORCPT ); Mon, 24 Jan 2022 15:00:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D70C04D63F; Mon, 24 Jan 2022 11:28:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2EB14B8119D; Mon, 24 Jan 2022 19:28:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A984C340E5; Mon, 24 Jan 2022 19:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052499; bh=S5wGeD/UHHh8DIKXW9frLb7k6IW0Fo+4rr8C207b6Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R9tSQkDeR2SyTzk2oxqnRVrzmmSDUv87bqBEKMYfpsh/GgkXHRVkKvBInYl6HtB1D vM9m5/MedjI75a4dHymwsiC958LedSHUjDyRfyh3sjH4Frkr6U0x8xOzRbdjpHP9Ic NucM/WwmjlpmO5quao1yUkgQmyvNGowEovmx5pqs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Toromanoff , Herbert Xu , Sasha Levin Subject: [PATCH 5.4 079/320] crypto: stm32/cryp - fix xts and race condition in crypto_engine requests Date: Mon, 24 Jan 2022 19:41:03 +0100 Message-Id: <20220124183956.427945438@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicolas Toromanoff [ Upstream commit d703c7a994ee34b7fa89baf21631fca0aa9f17fc ] 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 Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- 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 9b3511236ba25..92472a48c0454 100644 --- a/drivers/crypto/stm32/stm32-cryp.c +++ b/drivers/crypto/stm32/stm32-cryp.c @@ -669,8 +669,6 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err) else crypto_finalize_ablkcipher_request(cryp->engine, cryp->req, err); - - memset(cryp->ctx->key, 0, cryp->ctx->keylen); } static int stm32_cryp_cpu_start(struct stm32_cryp *cryp) -- 2.34.1