eal: check string parameter lengths
diff mbox series

Message ID e749b4c6e38c0f87bbef130aabdf1d1aa6b90d2c.1547640738.git.anatoly.burakov@intel.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • eal: check string parameter lengths
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Burakov, Anatoly Jan. 16, 2019, 12:12 p.m. UTC
When specifying parameters such as hugefile prefix from the
command-line, it is possibly to supply an empty string. This may
lead to various problems: for example, if hugefile prefix is
empty, the runtime config path construction may end up
looking like "/var/run/dpdk//_config", which will technically
work, but is wrong and places files in the wrong place.

To fix it, check lengths of such user-specified parameters for
hugefile prefix, as well as hugepage dir and user-specified
mbuf pool ops string.

Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_options.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Thomas Monjalon Jan. 17, 2019, 4:41 p.m. UTC | #1
16/01/2019 13:12, Anatoly Burakov:
> When specifying parameters such as hugefile prefix from the
> command-line, it is possibly to supply an empty string. This may
> lead to various problems: for example, if hugefile prefix is
> empty, the runtime config path construction may end up
> looking like "/var/run/dpdk//_config", which will technically
> work, but is wrong and places files in the wrong place.
> 
> To fix it, check lengths of such user-specified parameters for
> hugefile prefix, as well as hugepage dir and user-specified
> mbuf pool ops string.
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks

Patch
diff mbox series

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 3796dbf48..02de3b73e 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -1408,6 +1408,21 @@  eal_check_common_options(struct internal_config *internal_cfg)
 		RTE_LOG(ERR, EAL, "Invalid process type specified\n");
 		return -1;
 	}
+	if (internal_cfg->hugefile_prefix != NULL &&
+			strlen(internal_cfg->hugefile_prefix) < 1) {
+		RTE_LOG(ERR, EAL, "Invalid length of --" OPT_FILE_PREFIX " option\n");
+		return -1;
+	}
+	if (internal_cfg->hugepage_dir != NULL &&
+			strlen(internal_cfg->hugepage_dir) < 1) {
+		RTE_LOG(ERR, EAL, "Invalid length of --" OPT_HUGE_DIR" option\n");
+		return -1;
+	}
+	if (internal_cfg->user_mbuf_pool_ops_name != NULL &&
+			strlen(internal_cfg->user_mbuf_pool_ops_name) < 1) {
+		RTE_LOG(ERR, EAL, "Invalid length of --" OPT_MBUF_POOL_OPS_NAME" option\n");
+		return -1;
+	}
 	if (index(eal_get_hugefile_prefix(), '%') != NULL) {
 		RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
 			"option\n");