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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 14 Oct 2023 18:13:18 +0200
From: Andrew Lunn <>
To: Justin Stitt <>
Cc: Florian Fainelli <>,
	"David S. Miller" <>,
	Eric Dumazet <>,
	Jakub Kicinski <>, Paolo Abeni <>,,,
Subject: Re: [PATCH] net: cpmac: replace deprecated strncpy with strscpy

On Thu, Oct 12, 2023 at 08:53:30PM +0000, Justin Stitt wrote:
> strncpy() is deprecated for use on NUL-terminated destination strings
> [1] and as such we should prefer more robust and less ambiguous string
> interfaces.
> We expect mdio_bus_id to be NUL-terminated based on its use with
> snprint():
> |       snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT,
> |                                               mdio_bus_id, phy_id);
> Moreover, as this is the only use of mdio_bus_id, we can see that
> NUL-padding is not required.
> Considering the above, a suitable replacement is `strscpy` [2] due to
> the fact that it guarantees NUL-termination on the destination buffer
> without unnecessarily NUL-padding.
> Note that for the replacement involving cpmac_mii->id, the source
> buffer's length is equal to MII_BUS_ID_SIZE which could result in a
> buffer overread. However, there is no buffer overread since "cpmac-1"
> (the string copied into cpmac_mii->id) is smaller than MII_BUS_ID_SIZE
> thus meaning the previous usage of strncpy() here did _not_ have any
> overread bugs. Nonetheless, let's still favor strscpy() over strncpy().
> Link: [1]
> Link: [2]
> Link:
> Cc:
> Signed-off-by: Justin Stitt <>

Reviewed-by: Andrew Lunn <>


Powered by blists - more mailing lists