Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2220176ybg; Fri, 5 Jun 2020 08:29:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpqXpMHduVaSVVDwyIZK1HyrMMjeHWhiSkmzTGghF690sTe1rInz+RX+QhTxOr4n8mej1k X-Received: by 2002:a17:906:68ca:: with SMTP id y10mr2267058ejr.322.1591370955098; Fri, 05 Jun 2020 08:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591370955; cv=none; d=google.com; s=arc-20160816; b=pUxWNjTUcPafuT9sktgessCaCmV9UTwjSyrWkik7vb3faaqnyx/tKxH5eun29Q0n1l csqdhE7gi44aupTqTisHb76aKa8neMXC6SOpT7uYSY2zpVKyYilq3017WXo34+2kE/kS O80qXHeSTaZ21nFI1VvzJyaLv1qODJCKqqw2lqZamk/DmiWlfoP8gKYQkkyJ11SmywUi AocS4/ELqR8pNE3V9lRs2jkCOLQHbwWkrKsxtrsMCR924keu1jtbtyfmp/6MKho1/2q0 4Z1z7wJCHy4Izrh1XM3uesAH8jVBRb9Hzowt5aJTptlHtLvBYPJEtP6qmArtPAYsBxHV xhYQ== 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=AqjUdAV0eSeVgzmdoBhAtl0I2tJh0EYeJ8Lxk1njxlE=; b=jyCC4qz/FdZiVrqhDC+rQKr0F9Tro1S/ZoV/9Inpqs87vO7vNsWw7Ma4HvpFlMVyV8 T+6BPeDwVrEGKIM4+s9JVc1VS1SQ93VEkunrXRDw4T0Y+QEld0mXUG/pnoGl13s2fh5x Onp/1XNctGOqrqVk2t9WQ19TYC4RaBFRNDD7TK6JQK5UfTsVbYspFD/gq6+lqi2/Bmr6 2QHCDhnjqQnVYqjfra1iYJSPErBxIyTa0OnNlqJO5MIs6A5LDrk1dGuyZtCsn2Cmtdcg X8ryozjV6CG4aYIlzBKaCfunZp6jEqFQGJu/Ii9yeP6bu3T7b7CdjRFRQOIhm7m9/23r Do5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hb1FEGJc; 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 n19si752706edv.82.2020.06.05.08.28.41; Fri, 05 Jun 2020 08:29:15 -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=Hb1FEGJc; 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 S1727850AbgFEP0l (ORCPT + 99 others); Fri, 5 Jun 2020 11:26:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgFEP0k (ORCPT ); Fri, 5 Jun 2020 11:26:40 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4058C08C5C2 for ; Fri, 5 Jun 2020 08:26:40 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id u5so5278742pgn.5 for ; Fri, 05 Jun 2020 08:26:40 -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=AqjUdAV0eSeVgzmdoBhAtl0I2tJh0EYeJ8Lxk1njxlE=; b=Hb1FEGJcGKGXT6cLEc5+mKoFByGI75v/JS3V5JnikKJzHQfGRL5LNFK/kRVwPeymzn KLM6YgOaeQE1m6PhzzmrTyyrAyS6WLwbbfCVeFHF+ZmJIsx/7IaWhORJ+fGcarvE+Pwz FC64vYpIXt58BXX+h27dWOxjbSiAPbfJBW4OQEAxOB8Tbx7oJY40zWDwQpsA0bBYk1nn rT8VvP9eaV83x6AYoNPwr7pom9jUbFBi7yFKiTZPvCQmawfR1rSd/JLpKQwCf3fy3ElS wwHMz/JFa1OGLr53eTVb1c6QyBtqfw9NSI79OqnQqtR0VdkZlH/gKUGVXJyVrjn9SqDY qdRQ== 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=AqjUdAV0eSeVgzmdoBhAtl0I2tJh0EYeJ8Lxk1njxlE=; b=QcYKVne5u4N4r0B6HC52MD5nesXZlt+dtyDchSiePtMMHF3lM/GWWznHxGY8zmhzmC WXlfJeNE/KnsLY1af7hHv39x1/iDmtjTl+GoZZhOHJ1lfAXtGBhCWTcUC0BopCkQz3jp JyBjRfoVhINL89xBCdYHvv34wjnuq0RszEyCqvhMiI42GQ4iEmqo4wRU7SLlPK1Vvg/p Wmmh0pgP2+7XlOlq88At3JsYCfSgfE1OsKObsgi80yp3B46p743I6A2MAaCuBY5OCHvX 56TBwtXgAjkfrDASrX6XJLQ3MlKEfleDY1tGk0dqw7rQ029l5lXxA+N/EW/rMfTPTfKh Yp9A== X-Gm-Message-State: AOAM530Pe7nLjLzABskB5Erpt8apHmq5ksnzdh2OBCidll91CjSR7PmK Z95+l/N42CSN1dyW2p3XlLEZNw== X-Received: by 2002:a65:6810:: with SMTP id l16mr9525777pgt.390.1591370800353; Fri, 05 Jun 2020 08:26:40 -0700 (PDT) Received: from [10.110.1.78] ([45.135.186.59]) by smtp.gmail.com with ESMTPSA id s197sm8002426pfc.188.2020.06.05.08.26.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Jun 2020 08:26:39 -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> <20200604061811.GA28759@gondor.apana.org.au> <20200604065009.GA29822@gondor.apana.org.au> <20200605121703.GA3792@gondor.apana.org.au> From: Zhangfei Gao Message-ID: <47b747d2-3b27-4f39-85c9-204c2b8a92e1@linaro.org> Date: Fri, 5 Jun 2020 23:26:20 +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: <20200605121703.GA3792@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/5 下午8:17, Herbert Xu wrote: > On Fri, Jun 05, 2020 at 05:34:32PM +0800, Zhangfei Gao wrote: >> Will add a check after the copy. >> >>         strlcpy(interface.name, pdev->driver->name, sizeof(interface.name)); >>         if (strlen(pdev->driver->name) != strlen(interface.name)) >>                 return -EINVAL; > You don't need to do strlen. The function strlcpy returns the > length of the source string. > > Better yet use strscpy which will even return an error for you. > > Yes, good idea, we can use strscpy. +       int ret; -       strncpy(interface.name, pdev->driver->name, sizeof(interface.name)); +       ret = strscpy(interface.name, pdev->driver->name, sizeof(interface.name)); +       if (ret < 0) +               return ret; Will resend later, thanks Herbert.