Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1171325pxf; Fri, 2 Apr 2021 03:17:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcZjS04ap3cxZjl+NMh+v6uKQpSRC4lqj8pOaKM/UbpDFux7nLXAYtcJrM6O/acgrQhdcD X-Received: by 2002:a05:6602:2094:: with SMTP id a20mr10521976ioa.19.1617358662626; Fri, 02 Apr 2021 03:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617358662; cv=none; d=google.com; s=arc-20160816; b=pTQb/TL75Bxxst/6SBmaKlY53pZzyvbTwO0ELcx9GwsYUyVcK8Tyeu+4UAdXmiOw6M W9cqNC0UHYGSSXxa+fyWYf8ZeySoAgtwuyZc7PJk5cHFU7/PyE4m/16jnBwWYuyKR02C JiK7WjF14xTrMXzgVAhrK5MaxmKQD2cppW+caSPQEetN8tAvPhlKPd4uEC5AZb5CVsN9 i4ekAa/ECz+XbgOjljeWG6sKCuUBPQtsdPzqFYq29J7YL7yuzOqIVR+mr8vmTkcyaxkA y8tnMRx39qx/nQz55azjChAs4xTf+FNtRuSVEMPzXFuh6OUbztKuPeQD3Mml6c+rY9vS Ibdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=nNvqvBfwrlDlrq7AngHSzyaUf6namy09ljQ2AQXnRD4=; b=UK2bjNghZ5W0bPi2iaZ9b6fkXIyEjtFIyMscnNjaCfyPqa3+kBAHM1NEW/Y2Ag7ldZ 8GBF5zGlKfY0mryyx9gVOfJ+/tQiqWk3U3nwszeqbkT1McgYEf/E/TWllWChwMgVf5i/ 2Jdq1EXVnNJ/CyxBUpIQhlxJMpiPoxVRlEsG4yc+XPktW+Uyp1pvUd7ETPdYiGJskzYT 0wX6H0RvpjjkW8cPdb6M9plUPvrdXTeuzYn1Y3BzRMRqmYYuN/RKOskOxEL2S5jUJdrx K0hU7pNA+uQchu8kjgw4bpcO1dGJmsSh1r/vp52Ey3PIlgrrELtZNPduAf1HlVRsqXt1 CWdQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 15si7722455ilz.9.2021.04.02.03.17.23; Fri, 02 Apr 2021 03:17:42 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234207AbhDBKQr (ORCPT + 99 others); Fri, 2 Apr 2021 06:16:47 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:15905 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234161AbhDBKQp (ORCPT ); Fri, 2 Apr 2021 06:16:45 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FBbX04h4nzkhSZ; Fri, 2 Apr 2021 18:14:56 +0800 (CST) Received: from [10.67.103.10] (10.67.103.10) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Fri, 2 Apr 2021 18:16:29 +0800 Subject: Re: [PATCH] crypto: hisilicon/hpre - rsa key should not be empty To: Herbert Xu CC: , , , , , References: <1616739212-7751-1-git-send-email-yumeng18@huawei.com> <20210402071225.GA10423@gondor.apana.org.au> From: yumeng Message-ID: <7384e015-5514-d6b2-4215-beb1f4701adb@huawei.com> Date: Fri, 2 Apr 2021 18:16:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <20210402071225.GA10423@gondor.apana.org.au> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.10] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org ?? 2021/4/2 15:12, Herbert Xu ะด??: > On Fri, Mar 26, 2021 at 02:13:32PM +0800, Meng Yu wrote: >> We should ensure key is not empty before we set key. >> >> Signed-off-by: Meng Yu >> --- >> drivers/crypto/hisilicon/hpre/hpre_crypto.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c >> index 53068d2..7cf7d80 100644 >> --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c >> +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c >> @@ -1093,6 +1093,9 @@ static int hpre_rsa_setpubkey(struct crypto_akcipher *tfm, const void *key, >> struct hpre_ctx *ctx = akcipher_tfm_ctx(tfm); >> int ret; >> >> + if (!key || !keylen) >> + return -EINVAL; >> + >> ret = crypto_akcipher_set_pub_key(ctx->rsa.soft_tfm, key, keylen); > > Does this fix a real bug? Wouldn't the soft fallback setkey catch > this anyhow? > I think it is not a real bug, and soft fallback setkey can always catch the error. But our original intention was to make it don't go to 'xxx_set_pub_key' when the key is null, and it can return an error earlier. But maybe it is not good.