From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F8E4C1B08C for ; Thu, 15 Jul 2021 10:46:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E0DB613BC for ; Thu, 15 Jul 2021 10:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241672AbhGOKte (ORCPT ); Thu, 15 Jul 2021 06:49:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:57822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232055AbhGOKtd (ORCPT ); Thu, 15 Jul 2021 06:49:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 30C5C61380; Thu, 15 Jul 2021 10:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626345999; bh=DG3LveTVAU6PEbDuGHpdRTy1eY78W4ev4Y4ViSg12X8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DWnIO3kmhnVuKJw4p6WLmqkpE8Pgqv2yTuzK6P+ux+cfORUTE9Vo6+UGuOlPgVtao VdY28fLTSlIf8l2YrnwamxkP+dc8poqf1T91RLOJLtcYjZvMidL0yQCgv0n+SgrRmt WKHfD4L/d7HqmC0MglaQ4MmDKtKv33oZduzKIjRE= Date: Thu, 15 Jul 2021 12:46:33 +0200 From: Greg Kroah-Hartman To: Pavel Machek 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: References: <20210712060843.180606720@linuxfoundation.org> <20210712060857.335221127@linuxfoundation.org> <20210714194028.GA15200@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210714194028.GA15200@amd> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 14, 2021 at 09:40:28PM +0200, Pavel Machek wrote: > Hi! > > > [ Upstream commit 1339a7c3ba05137a2d2fe75f602311bbfc6fab33 ] > > > > 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. > > > > 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_request *async_req) > > sg_mark_end(sg); > > rctx->dst_sg = rctx->dst_tbl.sgl; > > ret is == 0 at this point. > > > - ret = dma_map_sg(qce->dev, rctx->dst_sg, rctx->dst_nents, dir_dst); > > - if (ret < 0) > > + dst_nents = dma_map_sg(qce->dev, rctx->dst_sg, rctx->dst_nents, dir_dst); > > + 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 = dma_map_sg(qce->dev, req->src, rctx->src_nents, dir_src); > > - if (ret < 0) > > + src_nents = dma_map_sg(qce->dev, req->src, rctx->src_nents, dir_src); > > + if (src_nents < 0) > > goto error_unmap_dst; > > rctx->src_sg = 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 > > This is also already in this 5.10.50 release. thanks, greg k-h