Commit 33ccbba4 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Jim Harris
Browse files

env/dpdk: add security checks to spdk_env_get_socket_id()



The underlying DPDK function we use reads an array
at the provided index without checking for any out
of bounds access. The array is RTE_MAX_LCORE elements
long, so always manually check against that to keep
our APIs safe.

This fixes potential crashes with lcore == SPDK_ENV_LCORE_ID_ANY

Change-Id: I3081b888275fbecba8ab95feb20d2074341e2fc7
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/425042


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent e06896b9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -84,6 +84,10 @@ spdk_env_get_next_core(uint32_t prev_core)
uint32_t
spdk_env_get_socket_id(uint32_t core)
{
	if (core >= RTE_MAX_LCORE) {
		return SPDK_ENV_SOCKET_ID_ANY;
	}

	return rte_lcore_to_socket_id(core);
}