patch 'vhost: remove use of strncpy' has been queued to stable release 25.11.5

Kevin Traynor ktraynor at redhat.com
Thu Dec 3 13:59:59 CET 2026


Hi,

FYI, your patch has been queued to stable release 25.11.5

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/08/26. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/5a002a45321145d51117edc55f6a2b35118f304b

Thanks.

Kevin

---
>From 5a002a45321145d51117edc55f6a2b35118f304b Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson at intel.com>
Date: Mon, 17 Aug 2026 14:42:42 +0100
Subject: [PATCH] vhost: remove use of strncpy

[ upstream commit fbdeee438ee569cc5ca907e53421f1290d8c97cb ]

The strlcpy is preferred over use of strncpy, which removes the need to
try and explicitly null-terminate some string buffers. We can also
simplify some name length handling as a result of this, as we no longer
need to use strnlen to clamp the length before calling the set_ifname
function.

Fixes: a277c7159876 ("vhost: refactor code structure")
Fixes: 0adb8eccc6a6 ("vhost: add VDUSE device creation and destruction")
Fixes: c171a2d5ff17 ("vhost: use strlcpy instead of strncpy")

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
Reviewed-by: Chengwen Feng <fengchengwen at huawei.com>
---
 lib/vhost/socket.c |  4 +---
 lib/vhost/vduse.c  |  2 +-
 lib/vhost/vhost.c  | 12 +++---------
 lib/vhost/vhost.h  |  2 +-
 4 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
index 70e582a18d..0943b3e9bb 100644
--- a/lib/vhost/socket.c
+++ b/lib/vhost/socket.c
@@ -208,5 +208,4 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
 {
 	int vid;
-	size_t size;
 	struct vhost_user_connection *conn;
 	int ret;
@@ -227,6 +226,5 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
 	}
 
-	size = strnlen(vsocket->path, PATH_MAX);
-	vhost_set_ifname(vid, vsocket->path, size);
+	vhost_set_ifname(vid, vsocket->path);
 
 	vhost_setup_virtio_net(vid, vsocket->use_builtin_virtio_net,
diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
index 5e71a50b22..58c8f4090b 100644
--- a/lib/vhost/vduse.c
+++ b/lib/vhost/vduse.c
@@ -819,5 +819,5 @@ vduse_device_create(const char *path, bool compliant_ol_flags, bool extbuf, bool
 	}
 
-	strncpy(dev->ifname, path, IF_NAME_SZ - 1);
+	strlcpy(dev->ifname, path, sizeof(dev->ifname));
 	dev->vduse_ctrl_fd = control_fd;
 	dev->vduse_dev_fd = dev_fd;
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 77712a6da2..f7936f1bc7 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -853,8 +853,7 @@ vhost_attach_vdpa_device(int vid, struct rte_vdpa_device *vdpa_dev)
 
 void
-vhost_set_ifname(int vid, const char *if_name, unsigned int if_len)
+vhost_set_ifname(int vid, const char *if_name)
 {
 	struct virtio_net *dev;
-	unsigned int len;
 
 	dev = get_device(vid);
@@ -862,9 +861,5 @@ vhost_set_ifname(int vid, const char *if_name, unsigned int if_len)
 		return;
 
-	len = if_len > sizeof(dev->ifname) ?
-		sizeof(dev->ifname) : if_len;
-
-	strncpy(dev->ifname, if_name, len);
-	dev->ifname[sizeof(dev->ifname) - 1] = '\0';
+	strlcpy(dev->ifname, if_name, sizeof(dev->ifname));
 }
 
@@ -992,6 +987,5 @@ rte_vhost_get_ifname(int vid, char *buf, size_t len)
 	len = RTE_MIN(len, sizeof(dev->ifname));
 
-	strncpy(buf, dev->ifname, len);
-	buf[len - 1] = '\0';
+	strlcpy(buf, dev->ifname, len);
 
 	return 0;
diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
index 5bf7d84963..6bed0b6717 100644
--- a/lib/vhost/vhost.h
+++ b/lib/vhost/vhost.h
@@ -878,5 +878,5 @@ int alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx);
 void vhost_attach_vdpa_device(int vid, struct rte_vdpa_device *dev);
 
-void vhost_set_ifname(int, const char *if_name, unsigned int if_len);
+void vhost_set_ifname(int vid, const char *if_name);
 void vhost_setup_virtio_net(int vid, bool enable, bool legacy_ol_flags, bool stats_enabled,
 	bool support_iommu);
-- 
2.56.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2026-12-03 12:52:41.373930123 +0000
+++ 0073-vhost-remove-use-of-strncpy.patch	2026-12-03 12:52:39.068938605 +0000
@@ -1 +1 @@
-From fbdeee438ee569cc5ca907e53421f1290d8c97cb Mon Sep 17 00:00:00 2001
+From 5a002a45321145d51117edc55f6a2b35118f304b Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit fbdeee438ee569cc5ca907e53421f1290d8c97cb ]
+
@@ -15 +16,0 @@
-Cc: stable at dpdk.org
@@ -45 +46 @@
-index 0b5d158fee..f8a4a8edcb 100644
+index 5e71a50b22..58c8f4090b 100644
@@ -48 +49 @@
-@@ -797,5 +797,5 @@ vduse_device_create(const char *path, bool compliant_ol_flags, bool extbuf, bool
+@@ -819,5 +819,5 @@ vduse_device_create(const char *path, bool compliant_ol_flags, bool extbuf, bool
@@ -56 +57 @@
-index 7e68b2c3be..fde8acb00c 100644
+index 77712a6da2..f7936f1bc7 100644
@@ -59 +60 @@
-@@ -777,8 +777,7 @@ vhost_attach_vdpa_device(int vid, struct rte_vdpa_device *vdpa_dev)
+@@ -853,8 +853,7 @@ vhost_attach_vdpa_device(int vid, struct rte_vdpa_device *vdpa_dev)
@@ -69 +70 @@
-@@ -786,9 +785,5 @@ vhost_set_ifname(int vid, const char *if_name, unsigned int if_len)
+@@ -862,9 +861,5 @@ vhost_set_ifname(int vid, const char *if_name, unsigned int if_len)
@@ -80 +81 @@
-@@ -916,6 +911,5 @@ rte_vhost_get_ifname(int vid, char *buf, size_t len)
+@@ -992,6 +987,5 @@ rte_vhost_get_ifname(int vid, char *buf, size_t len)
@@ -89 +90 @@
-index ee61f7415e..bb4708aed5 100644
+index 5bf7d84963..6bed0b6717 100644



More information about the stable mailing list