[v2,2/2] eal: prevent OOB read in rte_lcore_to_socket_id

Message ID 20221014075421.10300-2-markus.theil@tu-ilmenau.de (mailing list archive)
State Rejected, archived
Delegated to: Thomas Monjalon
Headers
Series [v2,1/2] eal: expose lcore pthread id |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance fail Performance Testing issues
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Markus Theil Oct. 14, 2022, 7:54 a.m. UTC
  rte_lcore_to_socket_id did not check the lcore_id
range before accessing an array with RTE_MAX_LCORE
elements.

Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
 lib/eal/common/eal_common_lcore.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/lib/eal/common/eal_common_lcore.c b/lib/eal/common/eal_common_lcore.c
index 812e62bcb3..af53efcc24 100644
--- a/lib/eal/common/eal_common_lcore.c
+++ b/lib/eal/common/eal_common_lcore.c
@@ -111,6 +111,9 @@  unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap)
 unsigned int
 rte_lcore_to_socket_id(unsigned int lcore_id)
 {
+	if (unlikely(lcore_id >= RTE_MAX_LCORE))
+		return -1;
+
 	return lcore_config[lcore_id].socket_id;
 }