[dpdk-stable] patch 'drivers: fix sprintf with snprintf' has been queued to LTS release 18.11.1

Kevin Traynor ktraynor at redhat.com
Thu Feb 7 14:25:14 CET 2019


Hi,

FYI, your patch has been queued to LTS release 18.11.1

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

Thanks.

Kevin Traynor

---
>From c2b777d67fd6fde5433cc8ffca1f8c6b2dd7ea9f Mon Sep 17 00:00:00 2001
From: Pallantla Poornima <pallantlax.poornima at intel.com>
Date: Mon, 7 Jan 2019 10:46:23 +0000
Subject: [PATCH] drivers: fix sprintf with snprintf

[ upstream commit a1e8241a919f7239d16e63fbc41549b2c951e1ae ]

sprintf function is not secure as it doesn't check the length of string.
More secure function snprintf is used

Fixes: 828d51d8fc ("bus/fslmc: refactor scan and probe functions")
Fixes: c22fab9a6c ("raw/dpaa2_qdma: support configuration APIs")
Fixes: e5cbdfc537 ("crypto/dpaa2_sec: add basic operations")
Fixes: b23d4e898a ("crypto/dpaa2_sec: add per dev mempool to store FLE")
Fixes: 623326dded ("crypto/dpaa2_sec: introduce poll mode driver")
Fixes: e7a45f3cc2 ("crypto/caam_jr: add UIO specific operations")
Fixes: f44bccadd8 ("crypto/caam_jr: add device basic operations")
Fixes: 7e3e2954e0 ("crypto/dpaa_sec: move mempool allocation to config")
Fixes: c3e85bdcc6 ("crypto/dpaa_sec: add crypto driver for NXP DPAA platform")

Signed-off-by: Pallantla Poornima <pallantlax.poornima at intel.com>
Acked-by: Akhil Goyal <akhil.goyal at nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c               |  4 ++--
 drivers/crypto/caam_jr/caam_jr.c            |  2 +-
 drivers/crypto/caam_jr/caam_jr_uio.c        | 13 ++++++-------
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  8 +++++---
 drivers/crypto/dpaa_sec/dpaa_sec.c          |  5 +++--
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c         |  2 +-
 6 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 565e0148f..2dcdca01f 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -295,6 +295,6 @@ rte_fslmc_scan(void)
 
 	/* Scan devices on the group */
-	sprintf(fslmc_dirpath, "%s/%d/devices", VFIO_IOMMU_GROUP_PATH,
-		groupid);
+	snprintf(fslmc_dirpath, sizeof(fslmc_dirpath), "%s/%d/devices",
+			VFIO_IOMMU_GROUP_PATH, groupid);
 	dir = opendir(fslmc_dirpath);
 	if (!dir) {
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index f505adf6b..190053ee6 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -2013,5 +2013,5 @@ caam_jr_dev_configure(struct rte_cryptodev *dev,
 
 	internals = dev->data->dev_private;
-	sprintf(str, "ctx_pool_%d", dev->data->dev_id);
+	snprintf(str, sizeof(str), "ctx_pool_%d", dev->data->dev_id);
 	if (!internals->ctx_pool) {
 		internals->ctx_pool = rte_mempool_create((const char *)str,
diff --git a/drivers/crypto/caam_jr/caam_jr_uio.c b/drivers/crypto/caam_jr/caam_jr_uio.c
index d94101c2f..bf872a220 100644
--- a/drivers/crypto/caam_jr/caam_jr_uio.c
+++ b/drivers/crypto/caam_jr/caam_jr_uio.c
@@ -285,9 +285,9 @@ uio_map_registers(int uio_device_fd, int uio_device_id,
 
 	/* Compose string: /sys/class/uio/uioX */
-	sprintf(uio_sys_root, "%s/%s%d", SEC_UIO_DEVICE_SYS_ATTR_PATH,
-		"uio", uio_device_id);
+	snprintf(uio_sys_root, sizeof(uio_sys_root), "%s/%s%d",
+			SEC_UIO_DEVICE_SYS_ATTR_PATH, "uio", uio_device_id);
 	/* Compose string: maps/mapY */
-	sprintf(uio_sys_map_subdir, "%s%d", SEC_UIO_DEVICE_SYS_MAP_ATTR,
-		uio_map_id);
+	snprintf(uio_sys_map_subdir, sizeof(uio_sys_map_subdir), "%s%d",
+			SEC_UIO_DEVICE_SYS_MAP_ATTR, uio_map_id);
 
 	/* Read first (and only) line from file
@@ -390,7 +390,6 @@ uio_job_ring *config_job_ring(void)
 	/* Find UIO device created by SEC kernel driver for this job ring. */
 	memset(uio_device_file_name, 0, sizeof(uio_device_file_name));
-
-	sprintf(uio_device_file_name, "%s%d", SEC_UIO_DEVICE_FILE_NAME,
-		job_ring->uio_minor_number);
+	snprintf(uio_device_file_name, sizeof(uio_device_file_name), "%s%d",
+			SEC_UIO_DEVICE_FILE_NAME, job_ring->uio_minor_number);
 
 	/* Open device file */
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index c24562b80..34c14f776 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -3373,5 +3373,6 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
 		goto init_error;
 	}
-	sprintf(cryptodev->data->name, "dpsec-%u", hw_id);
+	snprintf(cryptodev->data->name, sizeof(cryptodev->data->name),
+			"dpsec-%u", hw_id);
 
 	internals->max_nb_queue_pairs = attr.num_tx_queues;
@@ -3380,5 +3381,5 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
 	internals->token = token;
 
-	sprintf(str, "fle_pool_%d", cryptodev->data->dev_id);
+	snprintf(str, sizeof(str), "fle_pool_%d", cryptodev->data->dev_id);
 	internals->fle_pool = rte_mempool_create((const char *)str,
 			FLE_POOL_NUM_BUFS,
@@ -3411,5 +3412,6 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
 	int retval;
 
-	sprintf(cryptodev_name, "dpsec-%d", dpaa2_dev->object_id);
+	snprintf(cryptodev_name, sizeof(cryptodev_name), "dpsec-%d",
+			dpaa2_dev->object_id);
 
 	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index d83e74541..8958fd06a 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -2186,5 +2186,5 @@ dpaa_sec_dev_configure(struct rte_cryptodev *dev,
 
 	internals = dev->data->dev_private;
-	sprintf(str, "ctx_pool_%d", dev->data->dev_id);
+	snprintf(str, sizeof(str), "ctx_pool_%d", dev->data->dev_id);
 	if (!internals->ctx_pool) {
 		internals->ctx_pool = rte_mempool_create((const char *)str,
@@ -2392,5 +2392,6 @@ cryptodev_dpaa_sec_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused,
 	int retval;
 
-	sprintf(cryptodev_name, "dpaa_sec-%d", dpaa_dev->id.dev_id);
+	snprintf(cryptodev_name, sizeof(cryptodev_name), "dpaa_sec-%d",
+			dpaa_dev->id.dev_id);
 
 	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
index f474442d4..60621eb85 100644
--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -314,5 +314,5 @@ rte_qdma_vq_create(uint32_t lcore_id, uint32_t flags)
 	} else {
 		/* Allocate a Ring for Virutal Queue in VQ mode */
-		sprintf(ring_name, "status ring %d", i);
+		snprintf(ring_name, sizeof(ring_name), "status ring %d", i);
 		qdma_vqs[i].status_ring = rte_ring_create(ring_name,
 			qdma_dev.fle_pool_count, rte_socket_id(), 0);
-- 
2.19.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-02-07 13:19:55.700974004 +0000
+++ 0008-drivers-fix-sprintf-with-snprintf.patch	2019-02-07 13:19:55.000000000 +0000
@@ -1,8 +1,10 @@
-From a1e8241a919f7239d16e63fbc41549b2c951e1ae Mon Sep 17 00:00:00 2001
+From c2b777d67fd6fde5433cc8ffca1f8c6b2dd7ea9f Mon Sep 17 00:00:00 2001
 From: Pallantla Poornima <pallantlax.poornima at intel.com>
 Date: Mon, 7 Jan 2019 10:46:23 +0000
 Subject: [PATCH] drivers: fix sprintf with snprintf
 
+[ upstream commit a1e8241a919f7239d16e63fbc41549b2c951e1ae ]
+
 sprintf function is not secure as it doesn't check the length of string.
 More secure function snprintf is used
 
@@ -15,7 +17,6 @@
 Fixes: f44bccadd8 ("crypto/caam_jr: add device basic operations")
 Fixes: 7e3e2954e0 ("crypto/dpaa_sec: move mempool allocation to config")
 Fixes: c3e85bdcc6 ("crypto/dpaa_sec: add crypto driver for NXP DPAA platform")
-Cc: stable at dpdk.org
 
 Signed-off-by: Pallantla Poornima <pallantlax.poornima at intel.com>
 Acked-by: Akhil Goyal <akhil.goyal at nxp.com>
@@ -29,10 +30,10 @@
  6 files changed, 18 insertions(+), 16 deletions(-)
 
 diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
-index fa1505377..44c0827ce 100644
+index 565e0148f..2dcdca01f 100644
 --- a/drivers/bus/fslmc/fslmc_bus.c
 +++ b/drivers/bus/fslmc/fslmc_bus.c
-@@ -298,6 +298,6 @@ rte_fslmc_scan(void)
+@@ -295,6 +295,6 @@ rte_fslmc_scan(void)
  
  	/* Scan devices on the group */
 -	sprintf(fslmc_dirpath, "%s/%d/devices", VFIO_IOMMU_GROUP_PATH,
@@ -42,10 +43,10 @@
  	dir = opendir(fslmc_dirpath);
  	if (!dir) {
 diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
-index 45b281331..0263170fd 100644
+index f505adf6b..190053ee6 100644
 --- a/drivers/crypto/caam_jr/caam_jr.c
 +++ b/drivers/crypto/caam_jr/caam_jr.c
-@@ -2012,5 +2012,5 @@ caam_jr_dev_configure(struct rte_cryptodev *dev,
+@@ -2013,5 +2013,5 @@ caam_jr_dev_configure(struct rte_cryptodev *dev,
  
  	internals = dev->data->dev_private;
 -	sprintf(str, "ctx_pool_%d", dev->data->dev_id);
@@ -81,10 +82,10 @@
  
  	/* Open device file */
 diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
-index ef6e9c151..c2c22515d 100644
+index c24562b80..34c14f776 100644
 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
 +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
-@@ -3372,5 +3372,6 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
+@@ -3373,5 +3373,6 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
  		goto init_error;
  	}
 -	sprintf(cryptodev->data->name, "dpsec-%u", hw_id);
@@ -92,14 +93,14 @@
 +			"dpsec-%u", hw_id);
  
  	internals->max_nb_queue_pairs = attr.num_tx_queues;
-@@ -3379,5 +3380,5 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
+@@ -3380,5 +3381,5 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
  	internals->token = token;
  
 -	sprintf(str, "fle_pool_%d", cryptodev->data->dev_id);
 +	snprintf(str, sizeof(str), "fle_pool_%d", cryptodev->data->dev_id);
  	internals->fle_pool = rte_mempool_create((const char *)str,
  			FLE_POOL_NUM_BUFS,
-@@ -3410,5 +3411,6 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
+@@ -3411,5 +3412,6 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
  	int retval;
  
 -	sprintf(cryptodev_name, "dpsec-%d", dpaa2_dev->object_id);
@@ -108,17 +109,17 @@
  
  	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
 diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
-index 5caceef3f..39533a9cc 100644
+index d83e74541..8958fd06a 100644
 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c
 +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
-@@ -2470,5 +2470,5 @@ dpaa_sec_dev_configure(struct rte_cryptodev *dev,
+@@ -2186,5 +2186,5 @@ dpaa_sec_dev_configure(struct rte_cryptodev *dev,
  
  	internals = dev->data->dev_private;
 -	sprintf(str, "ctx_pool_%d", dev->data->dev_id);
 +	snprintf(str, sizeof(str), "ctx_pool_%d", dev->data->dev_id);
  	if (!internals->ctx_pool) {
  		internals->ctx_pool = rte_mempool_create((const char *)str,
-@@ -2676,5 +2676,6 @@ cryptodev_dpaa_sec_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused,
+@@ -2392,5 +2392,6 @@ cryptodev_dpaa_sec_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused,
  	int retval;
  
 -	sprintf(cryptodev_name, "dpaa_sec-%d", dpaa_dev->id.dev_id);


More information about the stable mailing list