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

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

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional 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/iol-aarch64-compile-testing success Testing PASS

Commit Message

Markus Theil Oct. 14, 2022, 6:21 a.m. UTC
  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 48c333cff1..94625c2ebc 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;
 }