[PATCH v5] ethdev: add buffer size parameter to rte_eth_dev_get_name_by_port()

Stephen Hemminger stephen at networkplumber.org
Mon Nov 16 19:37:11 CET 2026


On Sun, 15 Nov 2026 13:36:21 -0800
Stephen Hemminger <stephen at networkplumber.org> wrote:

> rte_eth_dev_get_name_by_port() uses strcpy() into a caller-provided
> buffer with no bounds checking. A mistaken caller that supplies a
> buffer smaller than RTE_ETH_NAME_MAX_LEN can overflow the buffer.
> 
> Add a size parameter and replace strcpy() with strlcpy(), returning
> -ERANGE if the name is truncated. The copy is now performed under
> the ethdev shared data lock so that the name cannot be mutated by
> another process between reading and copying.
> 
> Update all in-tree callers to pass the size of the buffer
> and add checks for return value.
> 
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---

I think this should go into 26.11 just because it is easier to do
API change in LTS version rather than having to do function versioning.
If not will resend with function versioning for 27.03


More information about the dev mailing list