Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp699806pxb; Tue, 5 Apr 2022 19:19:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUOWQ8NSyt18cExFoXTme8CSBSA7I7KxruIs6QCDWalKvY/wa76wAq3KL+kU6PIi+tVSA8 X-Received: by 2002:a17:90a:c504:b0:1bf:6d9f:65a6 with SMTP id k4-20020a17090ac50400b001bf6d9f65a6mr7291204pjt.204.1649211557971; Tue, 05 Apr 2022 19:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649211557; cv=none; d=google.com; s=arc-20160816; b=T96yhr7nLqXtKSRJuMZ7DNzE5dftM6hHdIL+0Ufw5kdXvm3l2zBp4Sdyvuzpnw1rNf VjCB1viGFy9prnuW50Ce0wvlFyVUbUSdsEDB8OeotKmfZ+f06D/P52ZNxKbLcc4iS2r+ BOn4gL4akEGNYunKkvg6IVuFDFQeTbCr1JYPeUGqec/sb7E0JxxS0Qvg9WMVaIJ1DwqU gozJ9zVa3YdCKfVsU597PZH2XczjYkhx+OjdACTFoEnbe3InbI4Sq7gjuPsqthV6D3NM Q/4bbHSIsu1ts5lHdu9tXEk7sWHjTHLgrqBDlGxRlQwEVsQQFJ5m62ZbEU7dj3PL1HcV Jt3w== 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=aU45G0oUgPSQlDDeVnZrlNHWxEA3Iktprm9earYWFEA=; b=LcJBldW2N4cJ5dPwXQpGXzaXx4LKr42lk2h3KyjEbTzIdJDvQLGpF7hzj/H1zhJp7m 71eorXpaTyB0yjHu5+Tds0IJGb4hdB+xxADrJEjwrML5RHlpNbwNy5nYk1JUWrkMdMGs kqBZtmQjz2tDg6OL9C8teedDavOSARElkXQbwh602V42E+x43C87HwE3eUp9T0MGXYBp z7wc3gLilEPAhebnlDv1Lxryl1uQpxOJB11dUu2QHASHJnk+b3dQ08yI1elXhBIKG/+b jGqOinywPxnsP6sueoEKVi7WZIhGCsyCvbbrN5r06jTcyARXJp/ScoVYYv3Xrv6VEYj0 upcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=et5aKI4e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23-20020a170902b19700b00153b2d164a0si13109028plr.168.2022.04.05.19.19.01; Tue, 05 Apr 2022 19:19:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=et5aKI4e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233570AbiDEIIO (ORCPT + 99 others); Tue, 5 Apr 2022 04:08:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232602AbiDEHxZ (ORCPT ); Tue, 5 Apr 2022 03:53:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FB221DA5C; Tue, 5 Apr 2022 00:49:09 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id F24CB616DE; Tue, 5 Apr 2022 07:49:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F32DC34111; Tue, 5 Apr 2022 07:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144948; bh=m9IdsWkhwEHDsIk1mPp3Sw2dqcl6n6tF8/nLt+2Yvdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=et5aKI4eY5d9tB+jPylBtP3nugH07hQ/ivzWYHfFAPyLkI1sLjO+bMUEW0mY1QCpn IqU12Y7w6yzlDMcCbkMAMzJjQIuLq25MiOVKEWj1CxyxCdH4CEAGNTs7d3DD1VXR1X vWpuLNtYSaERArgoIQfhnvtMDz+pzqHH6MgRCftE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gilad Ben-Yossef , Corentin Labbe , Herbert Xu , Sasha Levin Subject: [PATCH 5.17 0230/1126] crypto: ccree - dont attempt 0 len DMA mappings Date: Tue, 5 Apr 2022 09:16:17 +0200 Message-Id: <20220405070414.359472455@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gilad Ben-Yossef [ Upstream commit 1fb37b5692c915edcc2448a6b37255738c7c77e0 ] Refuse to try mapping zero bytes as this may cause a fault on some configurations / platforms and it seems the prev. attempt is not enough and we need to be more explicit. Signed-off-by: Gilad Ben-Yossef Reported-by: Corentin Labbe Fixes: ce0fc6db38de ("crypto: ccree - protect against empty or NULL scatterlists") Tested-by: Corentin Labbe Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/ccree/cc_buffer_mgr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index a5e041d9d2cf..11e0278c8631 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -258,6 +258,13 @@ static int cc_map_sg(struct device *dev, struct scatterlist *sg, { int ret = 0; + if (!nbytes) { + *mapped_nents = 0; + *lbytes = 0; + *nents = 0; + return 0; + } + *nents = cc_get_sgl_nents(dev, sg, nbytes, lbytes); if (*nents > max_sg_nents) { *nents = 0; -- 2.34.1