Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1061097ybg; Wed, 3 Jun 2020 23:14:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxxF+OOdFkHkFJphcjkIih50l9v908CmeFqcfFkug4RWPw+Bs7asyCnEFv1wWI91PQ3qBv X-Received: by 2002:aa7:d717:: with SMTP id t23mr2737108edq.304.1591251265235; Wed, 03 Jun 2020 23:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591251265; cv=none; d=google.com; s=arc-20160816; b=a5Hm00jm+Ogv0oPuVKZJqT8hAScjF7J+6TNOK25erMciGAUF2NbZiJAdaqjNtzWLbG MfIQZqsUujRlEv1/xgywKP/RLaRQ/q8Qw0u8Mk5x7DntgHIE0KL2ODxzIl7zrTx9rDRD q5WJmsPo/6Y7Du5E3HGIOUHIBC1beFiH+OJkHsTWkA1dDw84vtho7DLsEGSLVfbTzY9F P5/RVJeRPWqlzrYpbEqY1SXJRyzGm88j2ZbAprEo0jmkNbCZHdbEJ5Uyp1OwilX3Bx93 ZnKI3qq34YyhGxSSgUN75yMlPJ30qTFyoSjypFQQVpnw/+X/9MVUBMoJ3/Jo6EVRpX7g pXhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Sw/822Lzx4gGPvnJW8ZhfnQxJ/CLse2iXnOnbBACWxs=; b=rHq7VDxa4oW87s4znuuvzzdO6MKZwM6QS7x6HLOPEU6K2XS+FpakfyTGVzDQeev4nq b9Sz28v2Hqm6l5lf8Utd6dNmE8Ah88xqDHymx1SpFkPzN/x4EhoFUHml6vhu+Jv6nd67 SoIf0gRvsciZ4U6qyMzy2mzUnUVkFkJOJxNTMppscHaq0ENXX1guTb/MHaTDM+hw7zPm QzW0+uIiYwrGYhBA7NrOMY/b/jozKScXaw5u5ezZiTH/HFyUKwNG1sRziqKR8OjjCp8c 3OcnJENSGi5V3wDYTkuXL/mumOek3o4GZkrB3dzp6v0RcPg9N9FD8RrqY6fwz9xJ2/CJ GLNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qFwmskb7; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oz26si1143711ejb.252.2020.06.03.23.13.48; Wed, 03 Jun 2020 23:14:25 -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; dkim=pass header.i=@linaro.org header.s=google header.b=qFwmskb7; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbgFDGKw (ORCPT + 99 others); Thu, 4 Jun 2020 02:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbgFDGKv (ORCPT ); Thu, 4 Jun 2020 02:10:51 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9221BC05BD43 for ; Wed, 3 Jun 2020 23:10:51 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id t7so1783536plr.0 for ; Wed, 03 Jun 2020 23:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=Sw/822Lzx4gGPvnJW8ZhfnQxJ/CLse2iXnOnbBACWxs=; b=qFwmskb7rZ/DVhuRWSdVuv4TylJZJF1ESC/hegc9sCDe7xqo+CNcCH3w6h3JZRcLZ0 ZaRkLrM4SzA6w7mDJBtYOUB9/JPdIcH/l443Zbw8Dyuzm7/vjI3Tw7ZO1qZb91VaOB4P e6BxIXf4Xqdn7sl9xJPrqPfPeO0i9qZYGEN9zoEj58k8WXLB1S/rxp+gwTuvrNnh1rfJ sILXhHzv9jB0kyCAd+/rvQsZWj0CMi+cdXh1W25JQEn6cmeq37sYNJql1E/7FQrMCMNo 3rgC3HhEJPNsRpoCqGu+0WvJJlNhuPbN9zx0Ov/0LRZlaLUW2pmnawv0TmK6OBuiATy4 pxSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Sw/822Lzx4gGPvnJW8ZhfnQxJ/CLse2iXnOnbBACWxs=; b=GZfqUMfl0isNZVQjSuM4+yHJ5J2hYSQoh5kjoyxR4bX53vmjsPk4iCZcqxcTjTTECP oTt5aMjL7RJjVxyoa7uyIjAoAsyEN3EBCOgUvpq009hI3vU/cx3ZXdB9RV7cQCb5oNzx fzIJtB6kF7Kg+xPoOQXqBBvaWHXZg9Y+amJza+gowyoHgbWLWqzVyVg3HFJw+G4mbXfu xMkypUFiqKjGKloslTMgcTk3DUVoHZV+bq4iv3XIXR1bMjTlbPrJCTEDB6Q28JOMtPz4 UHRmkFT34LYZd7SK7/EfI7N2sGCc7Zm7WNRoYdEcg3VKqLi+Q51PNGbfR3+I9KSwhB7O yDZA== X-Gm-Message-State: AOAM5309+wfJNAU7JKfOLmUivpRYtndbkgALvKM5dtv6/XOdjveRR73m X/oDgWGHKl0zxHjQbZawr0U4Wg== X-Received: by 2002:a65:6694:: with SMTP id b20mr2910101pgw.303.1591251051118; Wed, 03 Jun 2020 23:10:51 -0700 (PDT) Received: from [10.15.5.98] ([45.135.186.21]) by smtp.gmail.com with ESMTPSA id b1sm4604480pjc.33.2020.06.03.23.10.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Jun 2020 23:10:50 -0700 (PDT) Subject: Re: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy To: Herbert Xu Cc: Greg Kroah-Hartman , Jonathan Cameron , wangzhou1 , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, kbuild-all@lists.01.org References: <202006032110.BEbKqovX%lkp@intel.com> <1591241524-6452-1-git-send-email-zhangfei.gao@linaro.org> <20200604033918.GA2286@gondor.apana.org.au> From: Zhangfei Gao Message-ID: Date: Thu, 4 Jun 2020 14:10:37 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200604033918.GA2286@gondor.apana.org.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 2020/6/4 上午11:39, Herbert Xu wrote: > On Thu, Jun 04, 2020 at 11:32:04AM +0800, Zhangfei Gao wrote: >> Use strlcpy to fix the warning >> warning: 'strncpy' specified bound 64 equals destination size >> [-Wstringop-truncation] >> >> Reported-by: kernel test robot >> Signed-off-by: Zhangfei Gao >> --- >> drivers/crypto/hisilicon/qm.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c >> index f795fb5..224f3e2 100644 >> --- a/drivers/crypto/hisilicon/qm.c >> +++ b/drivers/crypto/hisilicon/qm.c >> @@ -1574,7 +1574,7 @@ static int qm_alloc_uacce(struct hisi_qm *qm) >> .ops = &uacce_qm_ops, >> }; >> >> - strncpy(interface.name, pdev->driver->name, sizeof(interface.name)); >> + strlcpy(interface.name, pdev->driver->name, sizeof(interface.name)); > Should this even allow truncation? Perhaps it'd be better to fail > in case of an overrun? I think we do not need consider overrun, since it at most copy size-1 bytes to dest. From the manual: strlcpy()        This  function  is  similar  to  strncpy(), but it copies at most size-1 bytes to dest, always adds a terminating null        byte, And simple tested with smaller SIZE of interface.name,  only SIZE-1 is copied, so it is safe. -#define UACCE_MAX_NAME_SIZE    64 +#define UACCE_MAX_NAME_SIZE    4 Thanks