Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1121780pxk; Fri, 4 Sep 2020 00:41:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRXepBYjBt4U2LcnncpoDlCjGS/VdTPE8t1+BlgiYGKSX06HIP18iFhB6I0WIa/yvXTL6F X-Received: by 2002:a17:906:380d:: with SMTP id v13mr5875182ejc.152.1599205289212; Fri, 04 Sep 2020 00:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599205289; cv=none; d=google.com; s=arc-20160816; b=0FNY1nYjBWqVaaqjEb5XtYEq0m6r87OptOw/rQ5wUykEHS4ukve/vNdG6oH0T2vNX+ WXHXKh/z9noJURgDNFvnfUDMIEmttuspRzzEfZPeJ+8Zje0BZt0fDEhVeYspKoNP+wi8 2LTlZhoVP8/CK5g8JS9JF3fo6fakINJWdRuHrpRfBw/0Z5nZ1KB0iD4Tn77Z2Pd8yY1W r93YQ3dzBmHcdwy8yILzs7YBpFKVR19zpppFz87nmZlxdPNJL4uOddHPb3rH5hU69OzK f9yrZ8RJYb7Fc0N2qY+Ib0Pz70xVvRF6L0aknye5y/d5OhcYmanUsiHXK8l+zRqXRHYZ YrMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=c4WQJYrpa53pOftCo1abLvO9wpHJcPpmiAyhTVETCa8=; b=Rf/Blacd+WCF9nRHz88UG0iTc+p5GeY+bnZtNe4BM54GbSbnh5oX6FyjwzP97PFaB6 aU0ngqqlgH89TV43l3lahQGk3v5E2M7UCxN9t1Tzg2VVR3PRT1ZDLQ+ymgig1pPtJqvX QhHYVH0K/nfWQTfq39IsSrse5TAbXYPbmh3G73aWF0KX25x/RWWI10y/wwgSudHmNdpA 1f+HoINHqdP5pXr/ceyuNBzvr9I1Nton4FuoYjFYNAiIaDF9OPmC/CjmFzi66ms1cRt8 btzgl5BUJ3iwaYqlyVA1jx2fz/j1QTpyJlJ7B3JdVRbpBCzLEAaX1ftTXMK8sEKDUTZI ZFXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 a23si3506945ejk.229.2020.09.04.00.41.03; Fri, 04 Sep 2020 00:41:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726811AbgIDHkW (ORCPT + 99 others); Fri, 4 Sep 2020 03:40:22 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:42610 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbgIDHkW (ORCPT ); Fri, 4 Sep 2020 03:40:22 -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 1kE6KK-0000Lo-9Q; Fri, 04 Sep 2020 17:40:05 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Fri, 04 Sep 2020 17:40:04 +1000 Date: Fri, 4 Sep 2020 17:40:04 +1000 From: Herbert Xu To: "shenyang (M)" Cc: David Laight , "davem@davemloft.net" , "linux-kernel@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "xuzaibo@huawei.com" , "wangzhou1@hisilicon.com" Subject: Re: [PATCH RESEND 04/10] crypto: hisilicon/zip - replace 'sprintf' with 'scnprintf' Message-ID: <20200904074004.GA24815@gondor.apana.org.au> References: <1598238709-58699-1-git-send-email-shenyang39@huawei.com> <1598238709-58699-5-git-send-email-shenyang39@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 26, 2020 at 04:56:40PM +0800, shenyang (M) wrote: > > > > @@ -514,13 +514,16 @@ static int hisi_zip_core_debug_init(struct hisi_qm *qm) > > > struct debugfs_regset32 *regset; > > > struct dentry *tmp_d; > > > char buf[HZIP_BUF_SIZE]; > > > - int i; > > > + int i, ret; > > > > > > for (i = 0; i < HZIP_CORE_NUM; i++) { > > > if (i < HZIP_COMP_CORE_NUM) > > > - sprintf(buf, "comp_core%d", i); > > > + ret = scnprintf(buf, HZIP_BUF_SIZE, "comp_core%d", i); > > > else > > > - sprintf(buf, "decomp_core%d", i - HZIP_COMP_CORE_NUM); > > > + ret = scnprintf(buf, HZIP_BUF_SIZE, "decomp_core%d", > > > + i - HZIP_COMP_CORE_NUM); > > > + if (!ret) > > > + return -ENOMEM; > > > > and that is just so wrong - did you even try to test > > the 'buffer too small' code path? > > Do you means the check is unnecessary? No he's saying that your patch does the wrong thing when the string is truncated. Also ENOMEM is a strange error for that case. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt