[dpdk-dev] [PATCH v2] VFIO: Avoid to enable vfio while the module not loaded

Qiu, Michael michael.qiu at intel.com
Tue Dec 9 03:47:01 CET 2014


On 12/9/2014 2:47 AM, Burakov, Anatoly wrote:
> Hi Michael
>
>> I don't think so, if we check module "vfio", but if given  module name is
>> "vfio_xx", it will also correct if use strncmp.
> 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, replacing 

Yes, you are right, strncmp() will check 30 bytes if use sizeof(buffer).

But any issue of strcmp() ? This rountin cares about exactly match. I
think no need to convert to strncmp() if it does have other issue.

> fscanf with fgets would be better too, to make sure we never go over our buffer size when dealing with /proc/modules. 

If we use fgets, we need additional efforts to get the modname,  for
potential overflow issue, we can limit counts of fscanf(). like below:

fscanf(fd, "%30s %*[^\n]", mod_name);

Thanks,
Michael

>
> Thanks,
> Anatoly 
>



More information about the dev mailing list