Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1100309ybg; Thu, 4 Jun 2020 00:38:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA5HY6Pe/IItQJ5EKE4LRwbongStXIv6AVieJTVwS5Yuvr7xBPlehlZpQwV5P9fuoX2iCM X-Received: by 2002:a17:906:22d0:: with SMTP id q16mr2659409eja.455.1591256315682; Thu, 04 Jun 2020 00:38:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591256315; cv=none; d=google.com; s=arc-20160816; b=w6qd30CxWrfFSDq56NEdgt7F3seIc2Ntmbgvj2wE3ANCMrccFwdAFrRXPdS5hgTbU+ 5XWfhrX3P/u57riSoBNfXWpdTAIrjdMoDImj9dV0dU2hgOkO7VX+Q45w9/tNXfJWAY7V qm1aFMVvg9eYq1dzIh2Wjs7mz5lTVpy+Ji3DRNTQynF9Zo4TjCaiVaN9Az37MhudtIOf DiX3YrOiTCmQw+nkXpT9tlyYMSKn3a1oZIZUduALauVQtELFmHiWErLH4TAeBo3iQh8j zgv27KPda/FtNWY94sivoHEbN6tZ565l1gk7vue/v3iUNzn2lhZ+0MMDeygpyKes5Rnp 0Hug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date; bh=h/o/8bJhVMrVaX9J7b5RREO2+qRuvqVDD62Erj2hxpE=; b=ttGu+l8sEeMr3AI/MmZeZgubzXb8epcDN/owFA/A9gmcZYPvAX8zQ69OQS85B7ygEu gDRCb/2XFB/ypQJomoKXARXONgP75c+rCEkycD0j0TX5nyHQxCo9wmgKMMgtVPZWmBrP Nm/QQysorQaB95WXqzpgRIu6ETidOihtr81z5pLo3Y3YwthZ07b61NRnjRymTcCKzS92 LTRb/XiRel88Awi3jYfLm/vsAB/YflDW8ESGZa0nLp4TJW6XR5r7m8AmHDpK+1x/ZKAk mOJPTGl7VnMzrvhh5HYNvHzdKM1GlAki93j7aYGuzLPMnNu4VmVRBuYBSlEec/v00g4f YKKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 d10si1165034edo.83.2020.06.04.00.38.02; Thu, 04 Jun 2020 00:38:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727768AbgFDHh6 (ORCPT + 99 others); Thu, 4 Jun 2020 03:37:58 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:36742 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726422AbgFDHh5 (ORCPT ); Thu, 4 Jun 2020 03:37:57 -0400 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.0.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1jgkRi-0003bD-KS; Thu, 04 Jun 2020 17:37:51 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Thu, 04 Jun 2020 17:37:50 +1000 Date: Thu, 4 Jun 2020 17:37:50 +1000 From: Herbert Xu To: Linux Crypto Mailing List , Zhou Wang , Shukun Tan Subject: [PATCH] crypto: hisilicon - Cap block size at 2^31 Message-ID: <20200604073750.GA30866@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The function hisi_acc_create_sg_pool may allocate a block of memory of size PAGE_SIZE * 2^(MAX_ORDER - 1). This value may exceed 2^31 on ia64, which would overflow the u32. This patch caps it at 2^31. Reported-by: kernel test robot Fixes: d8ac7b85236b ("crypto: hisilicon - fix large sgl memory...") Signed-off-by: Herbert Xu diff --git a/drivers/crypto/hisilicon/sgl.c b/drivers/crypto/hisilicon/sgl.c index 0e8c7e324fb4..725a739800b0 100644 --- a/drivers/crypto/hisilicon/sgl.c +++ b/drivers/crypto/hisilicon/sgl.c @@ -66,7 +66,8 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev, sgl_size = sizeof(struct acc_hw_sge) * sge_nr + sizeof(struct hisi_acc_hw_sgl); - block_size = PAGE_SIZE * (1 << (MAX_ORDER - 1)); + block_size = 1 << (PAGE_SHIFT + MAX_ORDER <= 32 ? + PAGE_SHIFT + MAX_ORDER - 1 : 31); sgl_num_per_block = block_size / sgl_size; block_num = count / sgl_num_per_block; remain_sgl = count % sgl_num_per_block; -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt