Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp689058pxb; Tue, 5 Apr 2022 18:53:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL0b46WA8x8+q87Xy/MrlkorwfXEWqZgAC7qQRgHn5p+/8H2/JwJSOAmHuNuqQfw937shQ X-Received: by 2002:a05:6a00:2290:b0:4fa:a99e:2e21 with SMTP id f16-20020a056a00229000b004faa99e2e21mr6355996pfe.20.1649210001638; Tue, 05 Apr 2022 18:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210001; cv=none; d=google.com; s=arc-20160816; b=gEGZ+eK/pOvBTsR9FfrkpKd78aCuywAIC/Ja7OScJl5A6gpzV+NIPCtDoJe8T6FtPo nOgb1cm49txr16vwAc3EddM5VMhJJt56mEOdcOGGZD5MOQC9qXQ8j1AgzHxKiIzlJNDI rrqonLJe40N2Sk+j75HFz/1Mwl7zVCCxYXELQyBA0BUkXQDV7esatGxZaG/JlZ1KNAqd UCpUmwlfe4npqoJQhhiWSUKfISqXIVZET58x3rF8VICVtyrbyDFidCFRNADnuStTRT3o sqjGvadfsacM7z8Ncb/txm3W4DBKV1sdxAfTmAPeQX26Od0Kk8eBuOLzdidv9TNdB0tF /17g== 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=fhJyu8B6wqGtWb+WzXCGcA6St80EAygVfNRT6lslbUT5J03XlqF+CPOictQ5pZvu28 Xsnu3DgkvYF6oFEPblMwT5PwO1OEI620wQetGXY7h09qJ+lpP7AQr7IYBphvX2GYDvVr dZqA9cyLBF6Jwi4cYKtjA8unt/mg57lwqKuKoHcQ0WxCPStEpjrKW+SxAkQhmw5vaOES 4h2FOvbdurpHKaWZ2etRsFvQ7HfsajGNMNKIeKGlO3DwU28VSDUyJdgkWsSux/mBjJG8 jytfx0+MmweR0beNgFbArgd0sO0RL1lPZrgaVETIxXI+awkgEaJycUKcyo6NFuAeGs+i Fqcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="qIr/ID4T"; 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 d59-20020a17090a6f4100b001c6739ec79asi4341145pjk.160.2022.04.05.18.53.06; Tue, 05 Apr 2022 18:53:21 -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="qIr/ID4T"; 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 S1379037AbiDELkH (ORCPT + 99 others); Tue, 5 Apr 2022 07:40:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244740AbiDEIwh (ORCPT ); Tue, 5 Apr 2022 04:52:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 318851C909; Tue, 5 Apr 2022 01:43:02 -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 ams.source.kernel.org (Postfix) with ESMTPS id CAC32B81A0C; Tue, 5 Apr 2022 08:43:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35685C385A0; Tue, 5 Apr 2022 08:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148179; bh=m9IdsWkhwEHDsIk1mPp3Sw2dqcl6n6tF8/nLt+2Yvdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qIr/ID4T4kf6fETm6aAkPq5UAe0C31HShukJzS5oBpccu8VnBcALixluhiNMq7Mzj 65H5Wj+Rmfe3W2r6ad/2NVn4BjT5+FD/pLLBEppc5mXAP4JVLEUL8bVQng99+4ux77 JLjyBU6QA9/bJlxF8lRD5tK0nYVrWJJZSzwWAEXk= 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.16 0224/1017] crypto: ccree - dont attempt 0 len DMA mappings Date: Tue, 5 Apr 2022 09:18:57 +0200 Message-Id: <20220405070400.899991650@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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