[PATCH v5] ethdev: add buffer size parameter to rte_eth_dev_get_name_by_port()
Thomas Monjalon
thomas at monjalon.net
Thu Nov 19 01:30:15 CET 2026
16/11/2026 19:37, Stephen Hemminger:
> 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
This patch should have been merged earlier but was missed in next-net.
After verification, it looks safe.
Applied as an exception in -rc4, thanks.
More information about the dev
mailing list