From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.warmcat.com (mail.warmcat.com [163.172.24.82]) by dpdk.org (Postfix) with ESMTP id B93D41BA95 for ; Tue, 15 May 2018 09:33:13 +0200 (CEST) To: "Yao, Lei A" , "dev@dpdk.org" References: <152608956198.121204.14844325841690943774.stgit@localhost.localdomain> <152608967931.121204.3086768884047081432.stgit@localhost.localdomain> <2DBBFF226F7CF64BAFCA79B681719D953A44992E@SHSMSX101.ccr.corp.intel.com> From: Andy Green Message-ID: <24ddc6ec-87cf-5955-8fb8-dac4a268ac5b@warmcat.com> Date: Tue, 15 May 2018 15:32:58 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 In-Reply-To: <2DBBFF226F7CF64BAFCA79B681719D953A44992E@SHSMSX101.ccr.corp.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v5 03/16] bus/pci: replace strncpy dangerous code X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 May 2018 07:33:13 -0000 On 05/15/2018 02:12 PM, Yao, Lei A wrote: > Hi, Andy > > This patch will break the vfio-pci driver on my server. > I can't launch NIC with vfio-pci using testpmd. Could you have > a check on this? Thanks a lot! > > My server info: > OS: Ubuntu 16.04 LTS > gcc: 5.4.0 > kernel: 4.4.0 > CPU: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz > NIC: Ethernet Controller X710 for 10GbE SFP+ > > My Step: > 1. Bind NIC to vfio-pci driver > modprobe vfio-pci > dpdk-devbind.py -b vfio-pci [PCI address of NIC] > > 2. Launch testpmd; > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x03 -n 4 -- -i I don't have any nic to test with. But it doesn't matter the patch is indeed wrong... I just sent you and the list a fix on top of the incomplete patch. "bus/pci: correct the earlier strlcpy conversion" Sorry... -Andy >> -----Original Message----- >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Andy Green >> Sent: Saturday, May 12, 2018 9:48 AM >> To: dev@dpdk.org >> Subject: [dpdk-dev] [PATCH v5 03/16] bus/pci: replace strncpy dangerous >> code >> >> In function ‘pci_get_kernel_driver_by_path’, >> inlined from ‘pci_scan_one.isra.1’ at /home/agreen/projects/dpdk/ >> drivers/bus/pci/linux/pci.c:317:8: >> /home/agreen/projects/dpdk/drivers/bus/pci/linux/pci.c:57:3: error: >> ‘strncpy’ specified bound depends on the length of the source argument >> [-Werror=stringop-overflow=] >> strncpy(dri_name, name + 1, strlen(name + 1) + 1); >> >> Signed-off-by: Andy Green >> Acked-by: Pablo de Lara >> Fixes: d9a8cd9595f2 ("pci: add kernel driver type") >> Cc: stable@dpdk.org >> --- >> drivers/bus/pci/linux/pci.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c >> index 4630a8057..a73ee49c2 100644 >> --- a/drivers/bus/pci/linux/pci.c >> +++ b/drivers/bus/pci/linux/pci.c >> @@ -54,7 +54,7 @@ pci_get_kernel_driver_by_path(const char *filename, >> char *dri_name) >> >> name = strrchr(path, '/'); >> if (name) { >> - strncpy(dri_name, name + 1, strlen(name + 1) + 1); >> + strlcpy(dri_name, name + 1, sizeof(dri_name)); >> return 0; >> } >> >