From patchwork Wed Oct 27 13:30:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12587343 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3567C433EF for ; Wed, 27 Oct 2021 13:31:41 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9390360EFF for ; Wed, 27 Oct 2021 13:31:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9390360EFF Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=3xiZzaAC65+sIangZTKCxSu9I+8cT9LVEtn/P3XPHS0=; b=I/w0b/2KEChTD2 CCiPFmwk6/myD34ODvn041KBBAzPoouMHZIRHGKAnb7g7ARuCRDGWVMHi9FfW0l0hrWZxPA6KoBZb gQvgQUm+LqkLpSojv9fidpJIc7nmhV8l5B33QA+llSSTSfX+jXJP2mXpGwA1xDO7Lqe9cFyfbSEqC IAzVDzBXSWBAwQ1v+lOBFws8CdZAea3Xeiv84+on0+3BK6Lc7iUY/CLE8voVhZlVuWrPxhezKtRuU 8OgvdpMrMTNd5CoYYpRilj+kDbkIg82BTFATGnOd2PTuM9BgDdg6cmbEjCo850qqcneEixJBvR29V /O5DxVkx6fcARmxe5Yjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfj0Q-004z1Q-48; Wed, 27 Oct 2021 13:30:14 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfj0M-004z0Z-G0 for linux-arm-kernel@lists.infradead.org; Wed, 27 Oct 2021 13:30:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1635341410; x=1666877410; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BkK/TZLyRyOl87sayCRYS99QcdZzIba8r4AMDj5GxCQ=; b=uopChulYXSwkL3XL/qzThJ3DJXky7YesH1N+tpV4BPRJBR7MG1wsvuoN YRAAiLF/sr5sVDD+BsRTy6iA1hwmmmcXcbHp+Rpgr7AXqHS6jZheCEFTm YcB1cp4x8FiEvkbWZpCjOSGcKDMJ9oRRE406I+JKfUu6IDiAZqie6g1dF xhcBOxxw46vz3RGqTyMrI+Yk/pP+Lsb373UkNG4xVnefpzbCi72Ahs0WM yzvDc61etvYG9++zUI+kADitsGWrOL6UWixgvRNfDgRl6KyMr587AaeYL SymEwLjpNBYtqJd74WehusBkSl5caIm78QkbMZyM26k5SwE9Un59cEH3A A==; IronPort-SDR: C8w4r3XVy3FIOAtoHc818KUL1hhv0BRX+i50CmNLk4D7oCvU04PKCwAeaOhXwWvyPss/f+R6zc KUFM9+iPt7bnUUYZHXSBUc2OX/8VHBZYNPreKu1LIVgr81YbVHXzm7E5UzyInrQApygwD0gmMZ hJO7Iz4+TaL244WsD1t6Owbjdot06gPX0+LgLwrnBbjpOs4ueQgw+JPfS+MNfUlLcWEjWDUO3l gw/alQf8derbXvoXI8OcOxvdTTSyjJ3F/hzW4m0UvpPI5Dh2ZshKv585kXAP0NoExAk0lzdpQl Ae676hdlExkMerEWZe+3Ompe X-IronPort-AV: E=Sophos;i="5.87,186,1631602800"; d="scan'208";a="74442186" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 27 Oct 2021 06:30:06 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 27 Oct 2021 06:30:06 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 27 Oct 2021 06:30:03 -0700 From: Tudor Ambarus To: Subject: [PATCH] crypto: atmel-aes: Reestablish the correct tfm context at dequeue Date: Wed, 27 Oct 2021 16:30:01 +0300 Message-ID: <20211027133001.332635-1-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211027_063010_658919_1C372E94 X-CRM114-Status: UNSURE ( 8.56 ) X-CRM114-Notice: Please train this message. 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: , Cc: alexandre.belloni@bootlin.com, Tudor Ambarus , linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, linux-crypto@vger.kernel.org, weo@reccoware.de, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In case there were more requests from different tfms in the crypto queue, only the context of the last initialized tfm was considered. Fixes: ec2088b66f7a ("crypto: atmel-aes - Allocate aes dev at tfm init time") Reported-by: Wolfgang Ocker Signed-off-by: Tudor Ambarus --- drivers/crypto/atmel-aes.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c index 9391ccc03382..fe0558403191 100644 --- a/drivers/crypto/atmel-aes.c +++ b/drivers/crypto/atmel-aes.c @@ -960,6 +960,7 @@ static int atmel_aes_handle_queue(struct atmel_aes_dev *dd, ctx = crypto_tfm_ctx(areq->tfm); dd->areq = areq; + dd->ctx = ctx; start_async = (areq != new_areq); dd->is_async = start_async; @@ -1274,7 +1275,6 @@ static int atmel_aes_init_tfm(struct crypto_skcipher *tfm) crypto_skcipher_set_reqsize(tfm, sizeof(struct atmel_aes_reqctx)); ctx->base.dd = dd; - ctx->base.dd->ctx = &ctx->base; ctx->base.start = atmel_aes_start; return 0; @@ -1291,7 +1291,6 @@ static int atmel_aes_ctr_init_tfm(struct crypto_skcipher *tfm) crypto_skcipher_set_reqsize(tfm, sizeof(struct atmel_aes_reqctx)); ctx->base.dd = dd; - ctx->base.dd->ctx = &ctx->base; ctx->base.start = atmel_aes_ctr_start; return 0; @@ -1783,7 +1782,6 @@ static int atmel_aes_gcm_init(struct crypto_aead *tfm) crypto_aead_set_reqsize(tfm, sizeof(struct atmel_aes_reqctx)); ctx->base.dd = dd; - ctx->base.dd->ctx = &ctx->base; ctx->base.start = atmel_aes_gcm_start; return 0; @@ -1927,7 +1925,6 @@ static int atmel_aes_xts_init_tfm(struct crypto_skcipher *tfm) crypto_skcipher_set_reqsize(tfm, sizeof(struct atmel_aes_reqctx) + crypto_skcipher_reqsize(ctx->fallback_tfm)); ctx->base.dd = dd; - ctx->base.dd->ctx = &ctx->base; ctx->base.start = atmel_aes_xts_start; return 0; @@ -2154,7 +2151,6 @@ static int atmel_aes_authenc_init_tfm(struct crypto_aead *tfm, crypto_aead_set_reqsize(tfm, (sizeof(struct atmel_aes_authenc_reqctx) + auth_reqsize)); ctx->base.dd = dd; - ctx->base.dd->ctx = &ctx->base; ctx->base.start = atmel_aes_authenc_start; return 0;