From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1572124A066; Tue, 26 Aug 2025 13:22:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756214546; cv=none; b=Je/Ph2OHn3VmspzBB5TKiDBDS92x6Ln59iM7bTAGIWQIo8Av/JKzfolQZSjwaVOyfmQfR3D5P4WPPe7aV5S3vvSdfSniYcZgvnbvA8O2Lq5VFNL2aluhZOeND+6sC2ZlnWbXOn0+DULaTWtHE6PkpYMXO9GZDG2Gz2EDgzjbOn8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756214546; c=relaxed/simple; bh=9UelaFZU3PYmhUZ00wmXGZZGRaVfmxzGMRJTbET/IWE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PuDo7k2UBvezgKCLiIn/mT+G6lNMiAxdk6LzgLoz+5gxlBJgr/85r2EaH+svHU3w1Q/eTgnH7Utf0s0eqLj2T63QApu8zNgyd7m/+JbyC8QPBtfG5/aKZ8xBj/X9hmuv1Xu3IJ5KO3riE2ufN3bpmNH4CBIX4x2YRs65uvngf3M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fx5rd0q5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fx5rd0q5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AB05C113CF; Tue, 26 Aug 2025 13:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756214546; bh=9UelaFZU3PYmhUZ00wmXGZZGRaVfmxzGMRJTbET/IWE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fx5rd0q5K4Pa2Dg4Fs2jIsm63xnwTCvbAzmLCzoo+zI4fj2ozOw4JsLdnowRpUNQ8 jgHDGj2fDoIrJM0CtfSpTTZFYZ+jYnkTSXTP2gcgyYIRFYPBOFO6gp7BH6UI4VMuO9 kBkxRgO6ccWFJ1J5/10Su85XQUhWL3ZV5vs9xms0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhiqi Song , Chenghai Huang , Herbert Xu , Sasha Levin Subject: [PATCH 6.1 177/482] crypto: hisilicon/hpre - fix dma unmap sequence Date: Tue, 26 Aug 2025 13:07:10 +0200 Message-ID: <20250826110935.180917788@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110930.769259449@linuxfoundation.org> References: <20250826110930.769259449@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhiqi Song [ Upstream commit 982fd1a74de63c388c060e4fa6f7fbd088d6d02e ] Perform DMA unmapping operations before processing data. Otherwise, there may be unsynchronized data accessed by the CPU when the SWIOTLB is enabled. Signed-off-by: Zhiqi Song Signed-off-by: Chenghai Huang Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index ef02dadd6217..541f5eb76b6e 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -1461,11 +1461,13 @@ static void hpre_ecdh_cb(struct hpre_ctx *ctx, void *resp) if (overtime_thrhld && hpre_is_bd_timeout(req, overtime_thrhld)) atomic64_inc(&dfx[HPRE_OVER_THRHLD_CNT].value); + /* Do unmap before data processing */ + hpre_ecdh_hw_data_clr_all(ctx, req, areq->dst, areq->src); + p = sg_virt(areq->dst); memmove(p, p + ctx->key_sz - curve_sz, curve_sz); memmove(p + curve_sz, p + areq->dst_len - curve_sz, curve_sz); - hpre_ecdh_hw_data_clr_all(ctx, req, areq->dst, areq->src); kpp_request_complete(areq, ret); atomic64_inc(&dfx[HPRE_RECV_CNT].value); @@ -1769,9 +1771,11 @@ static void hpre_curve25519_cb(struct hpre_ctx *ctx, void *resp) if (overtime_thrhld && hpre_is_bd_timeout(req, overtime_thrhld)) atomic64_inc(&dfx[HPRE_OVER_THRHLD_CNT].value); + /* Do unmap before data processing */ + hpre_curve25519_hw_data_clr_all(ctx, req, areq->dst, areq->src); + hpre_key_to_big_end(sg_virt(areq->dst), CURVE25519_KEY_SIZE); - hpre_curve25519_hw_data_clr_all(ctx, req, areq->dst, areq->src); kpp_request_complete(areq, ret); atomic64_inc(&dfx[HPRE_RECV_CNT].value); -- 2.39.5