Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp804863pxb; Thu, 17 Feb 2022 15:22:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJXy1VM1iIzmKt+9v84gkhn7zqEQQtVHAZrRTbiLvfVInhHLljTtGlBRnIEl+4U0NWptHe X-Received: by 2002:a17:902:db0d:b0:14c:c1f9:47c4 with SMTP id m13-20020a170902db0d00b0014cc1f947c4mr4886955plx.56.1645140149187; Thu, 17 Feb 2022 15:22:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645140149; cv=none; d=google.com; s=arc-20160816; b=ufxUJLE+k+Zcz9x6VlJOcF9DcRNH1rhCMx/vLkQzLq5fDABriL8oe3e6rJFeA3mnnO AXI943lvL4CRJW5ESRcS4uUWi3q4JaunkpS5eB6ILvG6X/4e/qdDso03t7IEcBWdcZAd rEizv0Ffu7UrJo0lmCQMIlGFCB8e3iU6VSlVW8BTGasbbqKEMv135SBUzMnPTDyk9MVn 7owl5l0hvLMW2nOBjLAbxC8oE4znbXY15NPutn9u1tXkfIarmt8uHQfh1xYTSAbfae6j CzLrUEeLwHnT8R3OX5QHvieWxnHjbdbZT0DqWsmLpST+hYM6/xta544V6JaVWMhWL8hD kmGw== 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 :message-id:date:subject:cc:to:from; bh=FoT2PQUAVi5V0x99qqQUx7jPs5nzufizcgU0Zl6kc2M=; b=cUgzJlr1Z85HDwj+sfzNbXz94SSgx61SYlI28UJPH6gmIzh9rBHf7smsdOfLXB14vp bLSAUeuni4OaDY1L78J7ERwfKl4i4X4owPfOk2nO516q9Cw5noe2ZjJVFC19jph2hSEc /c/yXl3C3E33IiWn418lLAtjStX2L8A38BVH5WwfbVgq6RBt2OLHptMSJrsH3fcnWnlu ShLXm/Hmt9d7ORJP2Y5vLu+EilQkRmTAPywLvOMo8MTR5aBcPIeNXTM7OQGdG6mPArCo PEWv0/pN1DKFnm6k2s7cx4VnosQ2PEJZbScW4q7o2hbzS2E91anjRWCwTEvotWkLlqOn OoRw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s80si9397429pgs.657.2022.02.17.15.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:22:29 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2656A3C702; Thu, 17 Feb 2022 15:08:19 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233288AbiBQT1z (ORCPT + 99 others); Thu, 17 Feb 2022 14:27:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232139AbiBQT1x (ORCPT ); Thu, 17 Feb 2022 14:27:53 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 03C0710459A; Thu, 17 Feb 2022 11:27:38 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 90D5F113E; Thu, 17 Feb 2022 11:27:38 -0800 (PST) Received: from e122247.arm.com (E122209.Arm.com [10.50.65.148]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B4B863F70D; Thu, 17 Feb 2022 11:27:36 -0800 (PST) From: Gilad Ben-Yossef To: Gilad Ben-Yossef , Herbert Xu , "David S. Miller" Cc: Ofir Drang , Corentin Labbe , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] crypto: ccree: don't attempt 0 len DMA mappings Date: Thu, 17 Feb 2022 21:27:26 +0200 Message-Id: <20220217192726.612328-1-gilad@benyossef.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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") --- 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.25.1