lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 24 Jul 2017 20:32:07 +0000
From:   "Rustad, Mark D" <mark.d.rustad@...el.com>
To:     Florian Fainelli <f.fainelli@...il.com>
CC:     Salil Mehta <salil.mehta@...wei.com>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "yisen.zhuang@...wei.com" <yisen.zhuang@...wei.com>,
        "huangdaode@...ilicon.com" <huangdaode@...ilicon.com>,
        "lipeng321@...wei.com" <lipeng321@...wei.com>,
        "mehta.salil.lnk@...il.com" <mehta.salil.lnk@...il.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
        "linuxarm@...wei.com" <linuxarm@...wei.com>
Subject: Re: [PATCH V4 net-next 7/8] net: hns3: Add Ethtool support to HNS3
 driver


> On Jul 23, 2017, at 10:05 AM, Florian Fainelli <f.fainelli@...il.com> wrote:
>> +
>> +	strncpy(drvinfo->version, HNAE_DRIVER_VERSION,
>> +		sizeof(drvinfo->version));
>> +	drvinfo->version[sizeof(drvinfo->version) - 1] = '\0';
> 
> strlcpy() would probably do that for you.

You need to be careful about strlcpy - it does not completely write the destination buffer as strncpy does, and so can result in a kernel memory leak if the destination is not known to already be cleared.

>> +
>> +	strncpy(drvinfo->driver, HNAE_DRIVER_NAME, sizeof(drvinfo->driver));
>> +	drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0';
> 
> Same here

Same here

>> +
>> +	strncpy(drvinfo->bus_info, priv->dev->bus->name,
>> +		sizeof(drvinfo->bus_info));> +	drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0';
> 
> And here.

And here too. I haven't looked at this deeply enough to know whether a leak could be created by strlcpy here, but I wanted to raise it as something to be considered before switching to it. Blindly adopting strlcpy is hazardous as are tools that unconditionally recommend it.

--
Mark Rustad, Networking Division, Intel Corporation


Download attachment "signature.asc" of type "application/pgp-signature" (842 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ