From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id E95C53F9 for ; Tue, 9 Dec 2014 03:49:01 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 08 Dec 2014 18:47:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,542,1413270000"; d="scan'208";a="620756181" Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98]) by orsmga001.jf.intel.com with ESMTP; 08 Dec 2014 18:48:56 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.110.14) by pgsmsx106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 9 Dec 2014 10:47:04 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.240]) with mapi id 14.03.0195.001; Tue, 9 Dec 2014 10:47:02 +0800 From: "Qiu, Michael" To: "Burakov, Anatoly" , Michael Qiu , "dev@dpdk.org" Thread-Topic: [PATCH v2] VFIO: Avoid to enable vfio while the module not loaded Thread-Index: AQHQEFe5Z9KwEf2S2E2ARpK72Nbfmw== Date: Tue, 9 Dec 2014 02:47:01 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9DE19@SHSMSX101.ccr.corp.intel.com> References: <1417664219-19679-1-git-send-email-michael.qiu@intel.com> <1417687227-21854-1-git-send-email-michael.qiu@intel.com> <533710CFB86FA344BFBF2D6802E60286C9D920@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] VFIO: Avoid to enable vfio while the module not loaded X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Dec 2014 02:49:02 -0000 On 12/9/2014 2:47 AM, Burakov, Anatoly wrote:=0A= > Hi Michael=0A= >=0A= >> I don't think so, if we check module "vfio", but if given module name i= s=0A= >> "vfio_xx", it will also correct if use strncmp.=0A= > Sorry I missed this the last time. I don't think that is the case. If you= do strncmp on sizeof(buffer), strncmp will always check 30 bytes. That way= if you check vfio against vfio_xx, you'll get a mismatch. Of course, repla= cing =0A= =0A= Yes, you are right, strncmp() will check 30 bytes if use sizeof(buffer).=0A= =0A= But any issue of strcmp() ? This rountin cares about exactly match. I=0A= think no need to convert to strncmp() if it does have other issue.=0A= =0A= > fscanf with fgets would be better too, to make sure we never go over our = buffer size when dealing with /proc/modules. =0A= =0A= If we use fgets, we need additional efforts to get the modname, for=0A= potential overflow issue, we can limit counts of fscanf(). like below:=0A= =0A= fscanf(fd, "%30s %*[^\n]", mod_name);=0A= =0A= Thanks,=0A= Michael=0A= =0A= >=0A= > Thanks,=0A= > Anatoly =0A= >=0A= =0A=