Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1322786ybg; Thu, 4 Jun 2020 06:57:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKAV91JgGGNqSGEApBJAQGrj3CWs/QAtOlLGN/Qqb+QULRwd8DdUJYmA/SIiBFTXE8EJU/ X-Received: by 2002:a17:906:6d4b:: with SMTP id a11mr4194698ejt.108.1591279073180; Thu, 04 Jun 2020 06:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591279073; cv=none; d=google.com; s=arc-20160816; b=06MrtSIZz9vHrPhCs6NExgAx4cdP9cJq/ZBs6cMwwGuwwcmzeBgLW0JHRpV0duFAQq b5UV+Iyf3SC09EmhWYd2WMExKatMzIpwxeYBJEmAEYdk2ClX9YPKT2gwcpSRBVwFyOh4 GCRQwJh7EPJpcUWkvxut2DQis+gdLy8CDoPfnX6XuwrHAhsOPperbE0A7KzG0RPjtdnB LpHzzfOxxNChf+OY+OxJMjMqyFudEkUzCns48H+QXDLmucAENVvMJAfK96sS7FYRbLqz PGloTgcQ807rJQS2xnmxcvju/7F2tAfWzuH8/LxuCmv0EQCEdaxWMXpzBI6JMkhtjHEq Iorg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:to:subject; bh=SGogkPck1ZwlJxYl7XU/ubPkaHPnWqwmhynOKVbJHAs=; b=xdyVzYsd4s+hZYbiiP6vP3MSTCD2lqcZA0sy8KRCWslyhSf7eMZKLg7eKFA64Yo81f QZaASfYS4disQ2C4QqBwgzTTrU1N6G0CeJ6QNlEpRzTsbSJLPCba2ZtPHvGryAJhUlEB pJ3CpbiKf7ZizpZBb2DgDgYfkqAMXD8I3ydVe5Of/pkqeeGkvubonMFa942Q3Ls8cP6f AnT0LGsnKoiiwBAwyw/YkQi9Lu8VDfcXP1jDLRCzA71B2k5WdzuYLL8pmk4GWpw1eVqi 1+UBmxXxpZf43pcb/lgsL/JF1y4+EB2Fekvv5H3SwCRrsainPGLOBV5tsX0hsBKyaugG EIPg== 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 k12si1894290edj.143.2020.06.04.06.57.29; Thu, 04 Jun 2020 06:57:53 -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 S1728709AbgFDNyn (ORCPT + 99 others); Thu, 4 Jun 2020 09:54:43 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5788 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728679AbgFDNyn (ORCPT ); Thu, 4 Jun 2020 09:54:43 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id EA76962F8E9A3388A999 for ; Thu, 4 Jun 2020 21:54:41 +0800 (CST) Received: from [10.63.139.185] (10.63.139.185) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Thu, 4 Jun 2020 21:54:33 +0800 Subject: Re: [PATCH] crypto: hisilicon - Cap block size at 2^31 To: Herbert Xu , Linux Crypto Mailing List , Shukun Tan References: <20200604073750.GA30866@gondor.apana.org.au> From: Zhou Wang Message-ID: <5ED8FD19.1010502@hisilicon.com> Date: Thu, 4 Jun 2020 21:54:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20200604073750.GA30866@gondor.apana.org.au> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.63.139.185] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 2020/6/4 15:37, Herbert Xu wrote: > 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 Fine to me, Thanks! > > 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; >