Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3653568pxb; Mon, 24 Jan 2022 14:31:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrKbWbLbGHdr2DfWxiFtpIpDbLdpkIvHsXSa06vh46MbrI0Y4R+Kf/8GXRrHbHs7dMvk5d X-Received: by 2002:a17:90b:b0d:: with SMTP id bf13mr400247pjb.31.1643063486890; Mon, 24 Jan 2022 14:31:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063486; cv=none; d=google.com; s=arc-20160816; b=WkfOd8N5TGtQKobhFLVpgxnHweFlcKX0FEJRpm5SLoqaC1n4c4Zm7sJESETqG2jquC zLi9uZy+VZPFOu8KSb6MKP51QNkGFX8VjgXBeYpLE8NaE4+eXC8FIgq69HermXx5KhSs S6sadIKlcQCFTWDAVtJziXviSk8eT/t/YEOdUxpL5kS4myaXbpacERUaUmnj3JO2t5kG SdG9xcAHWlyOFHfyjMbA2cg3RYZ/tyFcgHujgwrZCUbHlVMPJyI1PWLyfkuNKkSLmkvP 2ekRtCH2epdqCiD0P01IqBStigspvTEQR620NR0RBnZTyqAE62xth/PMniih54TkwHfb a1QQ== 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=FKpfl+YZCTjGWfZd8rXANvpC89U2elijlTVvlKs7bHY=; b=m5K4i1WhvpPpDuvcVvUfgrHjrG8KFRiqcHRTE+r43jvFh9X/e3K/zekTqOdOig6Qvo D9aKzUB+K3PDRTNF8DwUy8vhkKauX2MwYLvbJ/azcg0q+OjpN1SlXKPBfM65cdtgKsV6 Sv8ufd4AJ84HIobA4kwI/apP9bdD79RYZP9QG/LIuntJGd2m+GtTOX0a/F1CIPuECSr0 tSUVM5xmf6LRxmVvmIpyOLPXREiOkKMDt+c1+L78kBtMKwaLZrTILFcIG4Cw4P9fFbVC 8BT5S9nQsffVllzJEGfUy6s61c/BUECHrKfTc2KJkbnyVJ/Tl/A7It6QBVITomUAbla4 po1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UqbNi8Rq; 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 mu12si861504pjb.0.2022.01.24.14.31.14; Mon, 24 Jan 2022 14:31: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=UqbNi8Rq; 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 S1587183AbiAXW1y (ORCPT + 99 others); Mon, 24 Jan 2022 17:27:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1454763AbiAXVdj (ORCPT ); Mon, 24 Jan 2022 16:33:39 -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 9BA26C075D16; Mon, 24 Jan 2022 12:21:33 -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 423B9B810BD; Mon, 24 Jan 2022 20:21:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60C1FC340E5; Mon, 24 Jan 2022 20:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055692; bh=Im0F7TeBzMVqLpyKF0wuta0Ts2zCgNoPJI3BvjCBY7M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UqbNi8RqKhfQEdNQVnlpFu9Hgv7YQtdGNt9ZNEOTULTISyULQuZDSexKHtHIPOw4f +OVCCPLIyl6MaXqxdhso8bKoJ3U6Ej48G7Y9LV6G5eBn5fLEkapb/YOICwnnbqE9TT f4fpz0tHxyWYfbJe1iCrmEWpIrbr7T4UHXmX/hgU= 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.15 235/846] crypto: stm32/cryp - fix lrw chaining mode Date: Mon, 24 Jan 2022 19:35:52 +0100 Message-Id: <20220124184109.039664716@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 fa97dc2d48b476ea98199d808d3248d285987e99 ] This fixes the lrw autotest if lrw uses the CRYP as the AES block cipher provider (as ecb(aes)). At end of request, CRYP should not update the IV in case of ECB chaining mode. Indeed the ECB chaining mode never uses the IV, but the software LRW chaining mode uses the IV field as a counter and due to the (unexpected) update done by CRYP while the AES block process, the counter get a wrong value when the IV overflow. Fixes: 5f49f18d27cd ("crypto: stm32/cryp - update to return iv_out") 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, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c index 061db567908ae..9943836a5c25c 100644 --- a/drivers/crypto/stm32/stm32-cryp.c +++ b/drivers/crypto/stm32/stm32-cryp.c @@ -644,7 +644,7 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err) /* Phase 4 : output tag */ err = stm32_cryp_read_auth_tag(cryp); - if (!err && (!(is_gcm(cryp) || is_ccm(cryp)))) + if (!err && (!(is_gcm(cryp) || is_ccm(cryp) || is_ecb(cryp)))) stm32_cryp_get_iv(cryp); if (cryp->sgs_copied) { -- 2.34.1