patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Michael Santana <msantana@redhat.com>
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>,
	dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'fix off-by-one errors in snprintf' has been queued to LTS release 18.11.3
Date: Fri, 21 Jun 2019 17:45:59 +0100	[thread overview]
Message-ID: <20190621164626.31219-15-ktraynor@redhat.com> (raw)
In-Reply-To: <20190621164626.31219-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to LTS release 18.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/26/19. 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-queue

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

Thanks.

Kevin Traynor

---
From 5eb73b34f8167cd001eee415893554c3c2bc6168 Mon Sep 17 00:00:00 2001
From: Michael Santana <msantana@redhat.com>
Date: Fri, 10 May 2019 10:53:12 -0400
Subject: [PATCH] fix off-by-one errors in snprintf

[ upstream commit f4be6a9a2903e68f5f04124eeb59325c17f1e1eb ]

snprintf guarantees to always correctly place a null terminator
in the buffer string. So manually placing a null terminator
in a buffer right after a call to snprintf is redundant code.

Additionally, there is no need to use 'sizeof(buffer) - 1' in snprintf as this
means we are not using the last character in the buffer. 'sizeof(buffer)' is
enough.

Signed-off-by: Michael Santana <msantana@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/net/qede/base/bcm_osal.c                        | 4 ++--
 drivers/net/qede/qede_filter.c                          | 2 +-
 drivers/net/vdev_netvsc/vdev_netvsc.c                   | 2 +-
 examples/multi_process/client_server_mp/shared/common.h | 2 +-
 examples/server_node_efd/shared/common.h                | 2 +-
 lib/librte_eal/common/eal_common_options.c              | 3 +--
 lib/librte_eal/common/eal_filesystem.h                  | 9 ++++-----
 lib/librte_eal/common/malloc_heap.c                     | 4 ++--
 8 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/net/qede/base/bcm_osal.c b/drivers/net/qede/base/bcm_osal.c
index 693328f11..9915df44f 100644
--- a/drivers/net/qede/base/bcm_osal.c
+++ b/drivers/net/qede/base/bcm_osal.c
@@ -129,5 +129,5 @@ void *osal_dma_alloc_coherent(struct ecore_dev *p_dev,
 
 	OSAL_MEM_ZERO(mz_name, sizeof(*mz_name));
-	snprintf(mz_name, sizeof(mz_name) - 1, "%lx",
+	snprintf(mz_name, sizeof(mz_name), "%lx",
 					(unsigned long)rte_get_timer_cycles());
 	if (core_id == (unsigned int)LCORE_ID_ANY)
@@ -168,5 +168,5 @@ void *osal_dma_alloc_coherent_aligned(struct ecore_dev *p_dev,
 
 	OSAL_MEM_ZERO(mz_name, sizeof(*mz_name));
-	snprintf(mz_name, sizeof(mz_name) - 1, "%lx",
+	snprintf(mz_name, sizeof(mz_name), "%lx",
 					(unsigned long)rte_get_timer_cycles());
 	if (core_id == (unsigned int)LCORE_ID_ANY)
diff --git a/drivers/net/qede/qede_filter.c b/drivers/net/qede/qede_filter.c
index 5e6571ca6..0beade6d5 100644
--- a/drivers/net/qede/qede_filter.c
+++ b/drivers/net/qede/qede_filter.c
@@ -291,5 +291,5 @@ qede_config_arfs_filter(struct rte_eth_dev *eth_dev,
 	 * not currently used so it has no significance.
 	 */
-	snprintf(mz_name, sizeof(mz_name) - 1, "%lx",
+	snprintf(mz_name, sizeof(mz_name), "%lx",
 		 (unsigned long)rte_get_timer_cycles());
 	mz = rte_memzone_reserve_aligned(mz_name, QEDE_MAX_FDIR_PKT_LEN,
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index a5fd64e0c..94d067b20 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -334,5 +334,5 @@ vdev_netvsc_sysfs_readlink(char *buf, size_t size, const char *if_name,
 	int ret;
 
-	ret = snprintf(in, sizeof(in) - 1, "/sys/class/net/%s/%s",
+	ret = snprintf(in, sizeof(in), "/sys/class/net/%s/%s",
 		       if_name, relpath);
 	if (ret == -1 || (size_t)ret >= sizeof(in))
diff --git a/examples/multi_process/client_server_mp/shared/common.h b/examples/multi_process/client_server_mp/shared/common.h
index ac9175524..6dd43fcac 100644
--- a/examples/multi_process/client_server_mp/shared/common.h
+++ b/examples/multi_process/client_server_mp/shared/common.h
@@ -50,5 +50,5 @@ get_rx_queue_name(unsigned id)
 	static char buffer[sizeof(MP_CLIENT_RXQ_NAME) + 2];
 
-	snprintf(buffer, sizeof(buffer) - 1, MP_CLIENT_RXQ_NAME, id);
+	snprintf(buffer, sizeof(buffer), MP_CLIENT_RXQ_NAME, id);
 	return buffer;
 }
diff --git a/examples/server_node_efd/shared/common.h b/examples/server_node_efd/shared/common.h
index b8b533d8c..130fd4f4e 100644
--- a/examples/server_node_efd/shared/common.h
+++ b/examples/server_node_efd/shared/common.h
@@ -62,5 +62,5 @@ get_rx_queue_name(unsigned int id)
 	static char buffer[sizeof(MP_NODE_RXQ_NAME) + 2];
 
-	snprintf(buffer, sizeof(buffer) - 1, MP_NODE_RXQ_NAME, id);
+	snprintf(buffer, sizeof(buffer), MP_NODE_RXQ_NAME, id);
 	return buffer;
 }
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index d4ab5e235..79efb15d0 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -259,6 +259,5 @@ eal_plugindir_init(const char *path)
 		struct stat sb;
 
-		snprintf(sopath, PATH_MAX-1, "%s/%s", path, dent->d_name);
-		sopath[PATH_MAX-1] = 0;
+		snprintf(sopath, sizeof(sopath), "%s/%s", path, dent->d_name);
 
 		if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
diff --git a/lib/librte_eal/common/eal_filesystem.h b/lib/librte_eal/common/eal_filesystem.h
index 89a3added..aaba88e04 100644
--- a/lib/librte_eal/common/eal_filesystem.h
+++ b/lib/librte_eal/common/eal_filesystem.h
@@ -39,5 +39,5 @@ eal_runtime_config_path(void)
 	static char buffer[PATH_MAX]; /* static so auto-zeroed */
 
-	snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
+	snprintf(buffer, sizeof(buffer), "%s/%s", rte_eal_get_runtime_dir(),
 			RUNTIME_CONFIG_FNAME);
 	return buffer;
@@ -51,5 +51,5 @@ eal_mp_socket_path(void)
 	static char buffer[PATH_MAX]; /* static so auto-zeroed */
 
-	snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
+	snprintf(buffer, sizeof(buffer), "%s/%s", rte_eal_get_runtime_dir(),
 			MP_SOCKET_FNAME);
 	return buffer;
@@ -71,5 +71,5 @@ eal_hugepage_info_path(void)
 	static char buffer[PATH_MAX]; /* static so auto-zeroed */
 
-	snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
+	snprintf(buffer, sizeof(buffer), "%s/%s", rte_eal_get_runtime_dir(),
 			HUGEPAGE_INFO_FNAME);
 	return buffer;
@@ -83,5 +83,5 @@ eal_hugepage_data_path(void)
 	static char buffer[PATH_MAX]; /* static so auto-zeroed */
 
-	snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
+	snprintf(buffer, sizeof(buffer), "%s/%s", rte_eal_get_runtime_dir(),
 			HUGEPAGE_DATA_FNAME);
 	return buffer;
@@ -95,5 +95,4 @@ eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir, int f_id
 	snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
 			eal_get_hugefile_prefix(), f_id);
-	buffer[buflen - 1] = '\0';
 	return buffer;
 }
diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index c6a6d4f6b..b8f26f2b3 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -1121,5 +1121,5 @@ malloc_heap_add_external_memory(struct malloc_heap *heap, void *va_addr,
 	}
 
-	snprintf(fbarray_name, sizeof(fbarray_name) - 1, "%s_%p",
+	snprintf(fbarray_name, sizeof(fbarray_name), "%s_%p",
 			heap->name, va_addr);
 
@@ -1270,5 +1270,5 @@ rte_eal_malloc_heap_init(void)
 			int socket_id = rte_socket_id_by_idx(i);
 
-			snprintf(heap_name, sizeof(heap_name) - 1,
+			snprintf(heap_name, sizeof(heap_name),
 					"socket_%i", socket_id);
 			strlcpy(heap->name, heap_name, RTE_HEAP_NAME_MAX_LEN);
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-06-21 17:22:12.527920053 +0100
+++ 0015-fix-off-by-one-errors-in-snprintf.patch	2019-06-21 17:22:11.727519035 +0100
@@ -1 +1 @@
-From f4be6a9a2903e68f5f04124eeb59325c17f1e1eb Mon Sep 17 00:00:00 2001
+From 5eb73b34f8167cd001eee415893554c3c2bc6168 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit f4be6a9a2903e68f5f04124eeb59325c17f1e1eb ]
+
@@ -14,2 +15,0 @@
-Cc: stable@dpdk.org
-
@@ -49 +49 @@
-index 7bdc3023f..fd4985861 100644
+index 5e6571ca6..0beade6d5 100644
@@ -60 +60 @@
-index ad13eac3b..edab63e3a 100644
+index a5fd64e0c..94d067b20 100644
@@ -63 +63 @@
-@@ -331,5 +331,5 @@ vdev_netvsc_sysfs_readlink(char *buf, size_t size, const char *if_name,
+@@ -334,5 +334,5 @@ vdev_netvsc_sysfs_readlink(char *buf, size_t size, const char *if_name,
@@ -93 +93 @@
-index 0c91024c4..512d5088e 100644
+index d4ab5e235..79efb15d0 100644
@@ -96 +96 @@
-@@ -261,6 +261,5 @@ eal_plugindir_init(const char *path)
+@@ -259,6 +259,5 @@ eal_plugindir_init(const char *path)
@@ -105 +105 @@
-index f2f83e712..5d21f07c2 100644
+index 89a3added..aaba88e04 100644
@@ -143 +143 @@
-index c5d254d8a..f9235932e 100644
+index c6a6d4f6b..b8f26f2b3 100644
@@ -146 +146 @@
-@@ -1119,5 +1119,5 @@ malloc_heap_create_external_seg(void *va_addr, rte_iova_t iova_addrs[],
+@@ -1121,5 +1121,5 @@ malloc_heap_add_external_memory(struct malloc_heap *heap, void *va_addr,
@@ -151 +151 @@
- 			seg_name, va_addr);
+ 			heap->name, va_addr);
@@ -153 +153 @@
-@@ -1335,5 +1335,5 @@ rte_eal_malloc_heap_init(void)
+@@ -1270,5 +1270,5 @@ rte_eal_malloc_heap_init(void)

  parent reply	other threads:[~2019-06-21 16:49 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21 16:45 [dpdk-stable] patch 'kni: fix build on RHEL8' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'examples: fix make clean when using pkg-config' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/ixgbe: fix unexpected link handler' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/fm10k: advertise supported RSS hash function' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/i40e: fix Tx threshold setup' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/ixgbe: " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/mlx5: fix missing validation of null pointer' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/mlx5: fix description of return value' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/mlx5: fix memory free on queue create error' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/bnxt: fix TSO' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/bnxt: check for error conditions in Tx path' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/bnxt: fix Tx batching' " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/bnxt: optimize " Kevin Traynor
2019-06-21 16:45 ` [dpdk-stable] patch 'net/vmxnet3: fix uninitialized variable' " Kevin Traynor
2019-06-21 16:45 ` Kevin Traynor [this message]
2019-06-21 16:46 ` [dpdk-stable] patch 'doc: robustify PDF build' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'doc: fix PDF with greek letter' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/cxgbe: do not dereference global config struct' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'examples/multi_process: do not dereference global config' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'examples/qos_sched: do not dereference global config struct' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'test/hash: use existing lcore API' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'config: disable armv8 crypto extension' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'examples/ip_fragmentation: fix Tx queues init' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'mem: ease init in a docker container' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'doc: fix Linux guide for arm64 cross-compilation' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'examples/multi_process: fix FreeBSD build' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'bpf: fix pseudo calls for program loaded from ELF' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'acl: fix build with some arm64 compiler' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/af_packet: fix RxQ errors stat' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/avp: " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/bnxt: " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/cxgbe: " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/kni: " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/mlx4: " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/mlx5: " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/null: " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/pcap: " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/ring: " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/szedata2: " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/tap: " Kevin Traynor
2019-06-27 16:48   ` Kevin Traynor
2019-06-28 10:00     ` David Marchand
2019-06-28 12:11       ` Thomas Monjalon
2019-06-21 16:46 ` [dpdk-stable] patch 'net/mlx5: fix order of items in NEON scatter' " Kevin Traynor
2019-06-21 16:46 ` [dpdk-stable] patch 'net/bnxt: fix RSS RETA indirection table ops' " Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190621164626.31219-15-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=msantana@redhat.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).