Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1074677ybg; Wed, 3 Jun 2020 23:45:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSf51o37/PiRUYpBZel5lOlp0Bg6QdAc/aFT/YNukZM5MA5qxAmKGS6SfIdZ44RzQL5B5k X-Received: by 2002:a17:906:5243:: with SMTP id y3mr2756317ejm.193.1591253108134; Wed, 03 Jun 2020 23:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591253108; cv=none; d=google.com; s=arc-20160816; b=qAWJvtVxisHi6qVLiVntcTas8q87DxTfzwKsiSU0oadnfHmgWh/pjavDmci9NI9zL5 /gimRX6uOZMiqG+IvOkeJmwm0Z49sdpX+nwAhqVBCjaNz5bnJ0dAEPl5lmvV207FEy1o Nsq3CgGHGbomhYOVlnX9gH+6xfbIokWCGIEs8BfZmStV4EGZDmxZ7ekXralD9ahxFZNQ wy9my/RByryP5VkB/hTCKwRqczFZfeGVclxU6EGyAn1bxtiSvZsYW7yq+obCWN1AJWY7 /b79hxTOECmsf7+HWzOM7sWc9N+nRwY7ip+3/Pe37kXKKustxUaAFJCaZzWIvynFmTW/ PwNg== 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=lQVlXH+uj/MULxrEGj2byT6IBDKh5uPIe65HnVp2khs=; b=qj4Hg8WkPiR1h9kLKIqeF8BeBcBqwjLBscZXn9QaBpxKd/JfO/5NprXrr8fnPDnAN3 9zn4CvD1BTmJEoAVIP70b6f4NntkgGkUeMxoZ6qB4l+8dOp/Ny590OWtDqdbQactXPzA goqXYY6p2h7FeIhIOA8wMbxZf5SbVJNruOsLR8jqy/aelm666mDw3QiRxmAOY2Fp/7VE +kT8/YugsbxK0mXQWT4YssyjoWPQmV6nJWiq46SCZFWWOjBo7tqMUccIglbypp1pHyrn ioDRztCCGkShXqhe5o7zZwBc3RUQ+BMstaJMBFUCVPSQmzWfPwl3Iq2qXFfC5AV883/3 CT6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gzRnbTkc; 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 v15si1185479edq.373.2020.06.03.23.44.44; Wed, 03 Jun 2020 23:45:08 -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=gzRnbTkc; 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 S1727103AbgFDGo2 (ORCPT + 99 others); Thu, 4 Jun 2020 02:44:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726979AbgFDGo2 (ORCPT ); Thu, 4 Jun 2020 02:44:28 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22F34C03E96D for ; Wed, 3 Jun 2020 23:44:28 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id e9so3013223pgo.9 for ; Wed, 03 Jun 2020 23:44:28 -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=lQVlXH+uj/MULxrEGj2byT6IBDKh5uPIe65HnVp2khs=; b=gzRnbTkcAnqvYEoVW9YseGY+0u1VoTMW/IO49nxbU4/b5h6mTCySH8tG+xs+BPJv/6 KRDGlwtV9Ah7167fzuEQ8xp4anjyd5TQkJJ69SvgbXyirs97ICE1UiVX3L19uqWuQjAP 3sot+5jrOtfXbLnpKCD/twibMkrA8D4z22h6fVm1qdzWoymfGSQkMemFvoN8iU3SWC3J 10VJ1+++UoYEjyFX96NS4Co2pCuWJ/3yrjzugj9djTKFrXCDsNYr3XinRwGWguYuoCwg fyPAolJ41+4q6j+lvVYWBlvSj23VuYFXKER+6olegZJTTXe1Cl3lXoVoe6USONUNZocH Fz9w== 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=lQVlXH+uj/MULxrEGj2byT6IBDKh5uPIe65HnVp2khs=; b=jfSZTFZh3Rqcm/Mjb6wNiVpu8rb9JDCmbw7QLK2UsW+JkmBefjECQQ7WkogzoABycn 9O+e+kuo8N3L0F+WieigEk5x2UtbRrwu7uuCZeAiooHF6plYYeojnlhqt4S0+SC/5PwY OkLlFjFbj7a5UMk7uDrWEZayo5etp6BO+lVG6xPkjuQYPOksQejydtFou2GkAMoy9Gf6 bjEsHOHUNDZBcE8fakfdJ2mesfHhj6FpvjkiOCgi5EqbrmMF6lAWJjKh/lsqHym8tqjl WEF+oILiAikPRv8sCzU0kTKHofDnXDwDgi9lvIHhFSQQBPPI80TizfLV6Ou6DmZfTX9Q am1A== X-Gm-Message-State: AOAM533g7Ijrt9Fz4e03bvdfRkkVKUB/7yEsD2JlNCtBxgs8S1XSM1Tz Lj3C3oZdpPMbs+oHy1Q/he1lQg== X-Received: by 2002:a63:ad43:: with SMTP id y3mr2934343pgo.435.1591253067552; Wed, 03 Jun 2020 23:44:27 -0700 (PDT) Received: from [10.15.1.238] ([45.135.186.21]) by smtp.gmail.com with ESMTPSA id b140sm3461949pfb.119.2020.06.03.23.44.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Jun 2020 23:44:27 -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> From: Zhangfei Gao Message-ID: Date: Thu, 4 Jun 2020 14:44:16 +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: <20200604061811.GA28759@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 下午2:18, Herbert Xu wrote: > On Thu, Jun 04, 2020 at 02:10:37PM +0800, Zhangfei Gao wrote: >>> 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 > That's not what I meant. As it is if you do exceed the limit the > name is silently truncated. Wouldn't it be better to fail the > allocation instead? I think it is fine. 1. Currently the name size is 64, bigger enough. Simply grep in driver name, 64 should be enough. We can make it larger when there is a request. 2. it does not matter what the name is, since it is just an interface. cat /sys/class/uacce/hisi_zip-0/flags cat /sys/class/uacce/his-0/flags should be both fine to app only they can be distinguished. 3. It maybe a hard restriction to fail just because of a long name. What do you think. Thanks