Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp674238pxv; Wed, 14 Jul 2021 12:44:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze0NrugDLKlUZELT0YZGjrqIb1nSycwgi+6lK79lo1MmYPYhuGXMi32scaBd2sv3Auq0zw X-Received: by 2002:a05:6602:1207:: with SMTP id y7mr8440157iot.196.1626291853483; Wed, 14 Jul 2021 12:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626291853; cv=none; d=google.com; s=arc-20160816; b=xwd+WNxQhuHHC9JqaW/YVmo0s4ktrkK7AylX9NnMeiT7WkEyP/yAHR7w3TO+cp7Zqc 8eXEngpavCdVon9VfM/PnLAUI2RIcFdXU29PcZoTM1fuTkzvwwxZI+69DG/9Wt7FS19A vw5vZRhY42lTlQ0ukzzNnkVqnF9ejQAB6d3G48DwpDj7DTCyjuNkPTBJi8l15H/5rTaF eX+g2NP+KjCKtFeziyGIKzS2lPdeQbcq7O0c74K3QPaTi6Co/SY22Cu52iABHcXIhHiE ueHkIMCP4bMSVeXwsaVjrE4x3xy71jXXlWak7N4Hy4zNifK92WhnIm6Z8tBmc03sLB+r UcJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ctQnMT58wbubA4h/hSRvyHAQm1HKffV2hyNcqYeseV8=; b=XT3pTM6JK/YDc3liP8mHawXZurLuviVNacASjLFjWvynZ0KClVKWNpZYMvjwlbbco8 DnBt7tG6pcGAmLiQ+IPj5g2zBQPBIrYHzxMp2Eq/ER32lTOC4K32PV81HHtviD9L74ya ayQRIGNWEVur/anC08DuTprdSCm8gIMA9ndQJWukEXCpWp/TSjBTOq37eHNeDi6H484u qirfekHV8wtR0Ps0kLDTxqLKPBIHy3gluDWlEQUPNjU1S8FKeEwmltVFV8Bjdk8xoE4e fRCgJx3emwWxJ7GOiaIsNeO5hxqzaSlLWI7khFbm26OT5MedvNkWWd/xUjYmNPJf7HB+ +9Aw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d18si3061365ilo.140.2021.07.14.12.44.00; Wed, 14 Jul 2021 12:44:13 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237491AbhGNTqF (ORCPT + 99 others); Wed, 14 Jul 2021 15:46:05 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:44424 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235431AbhGNTnY (ORCPT ); Wed, 14 Jul 2021 15:43:24 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 9871B1C0B98; Wed, 14 Jul 2021 21:40:29 +0200 (CEST) Date: Wed, 14 Jul 2021 21:40:28 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Thara Gopinath , Herbert Xu , Sasha Levin Subject: Re: [PATCH 5.10 129/593] crypto: qce: skcipher: Fix incorrect sg count for dma transfers Message-ID: <20210714194028.GA15200@amd> References: <20210712060843.180606720@linuxfoundation.org> <20210712060857.335221127@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bg08WKrSYDhXBjb5" Content-Disposition: inline In-Reply-To: <20210712060857.335221127@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > [ Upstream commit 1339a7c3ba05137a2d2fe75f602311bbfc6fab33 ] >=20 > Use the sg count returned by dma_map_sg to call into > dmaengine_prep_slave_sg rather than using the original sg count. dma_map_= sg > can merge consecutive sglist entries, thus making the original sg count > wrong. This is a fix for memory coruption issues observed while testing > encryption/decryption of large messages using libkcapi framework. >=20 > Patch has been tested further by running full suite of tcrypt.ko tests > including fuzz tests. This still needs more work AFAICT. > index a2d3da0ad95f..5a6559131eac 100644 > --- a/drivers/crypto/qce/skcipher.c > +++ b/drivers/crypto/qce/skcipher.c > @@ -122,21 +122,22 @@ qce_skcipher_async_req_handle(struct crypto_async_r= equest *async_req) > sg_mark_end(sg); > rctx->dst_sg =3D rctx->dst_tbl.sgl; ret is =3D=3D 0 at this point. > - ret =3D dma_map_sg(qce->dev, rctx->dst_sg, rctx->dst_nents, dir_dst); > - if (ret < 0) > + dst_nents =3D dma_map_sg(qce->dev, rctx->dst_sg, rctx->dst_nents, dir_d= st); > + if (dst_nents < 0) > goto error_free; And we go to the error path, and return ret... instead of returning failure. > if (diff_dst) { > - ret =3D dma_map_sg(qce->dev, req->src, rctx->src_nents, dir_src); > - if (ret < 0) > + src_nents =3D dma_map_sg(qce->dev, req->src, rctx->src_nents, dir_src); > + if (src_nents < 0) > goto error_unmap_dst; > rctx->src_sg =3D req->src; Same problem happens here. The problem is already fixed in the mainline; I believe we want that in 5.10-stable at least. commit a8bc4f5e7a72e4067f5afd7e98b61624231713ca Author: Wei Yongjun Date: Wed Jun 2 11:36:45 2021 +0000 crypto: qce - fix error return code in qce_skcipher_async_req_handle() Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Fixes: 1339a7c3ba05 ("crypto: qce: skcipher: Fix incorrect sg count for dma transfers") Reported-by: Hulk Robot Signed-off-by: Wei Yongjun =20 Best regards, Pavel --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --bg08WKrSYDhXBjb5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmDvPawACgkQMOfwapXb+vJgCgCgs86Ch90+Sx6C+nZfUprneMWn 60kAoLFLd57INRSDiSOmjrqyGLrF4RxM =PjM2 -----END PGP SIGNATURE----- --bg08WKrSYDhXBjb5--