[dpdk-stable] patch 'examples/performance-thread: fix out-of-bounds sched array' has been queued to LTS release 16.11.4

luca.boccassi at gmail.com luca.boccassi at gmail.com
Mon Oct 30 16:35:10 CET 2017


Hi,

FYI, your patch has been queued to LTS release 16.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/01/17. So please
shout if anyone has objections.

Thanks.

Kind regards,
Luca Boccassi

---
>From 21e77ae83e5939c5f95fcdd464833b1e3896d93a Mon Sep 17 00:00:00 2001
From: Slawomir Mrozowicz <slawomirx.mrozowicz at intel.com>
Date: Wed, 20 Sep 2017 09:47:34 +0200
Subject: [PATCH] examples/performance-thread: fix out-of-bounds sched array

[ upstream commit 72481c87ec80542cabf65fa8ad32ac381ee5ce4e ]

Overrunning array schedcore of 128 8-byte elements at element index 128
using index core id.
Fixed by correct check index lcoreid condition and
change type of lcoreid to unsigned.

Coverity issue: 143459, 143461
Fixes: 116819b9ed0d ("examples/performance-thread: add lthread subsystem")

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz at intel.com>
Acked-by: Michal Jastrzebski <michalx.k.jastrzebski at intel.com>
---
 examples/performance-thread/common/lthread.h       |  2 +-
 examples/performance-thread/common/lthread_sched.c | 14 ++++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/examples/performance-thread/common/lthread.h b/examples/performance-thread/common/lthread.h
index 8c77af82e..01843ba5a 100644
--- a/examples/performance-thread/common/lthread.h
+++ b/examples/performance-thread/common/lthread.h
@@ -83,7 +83,7 @@ int _lthread_desched_sleep(struct lthread *lt);
 
 void _lthread_free(struct lthread *lt);
 
-struct lthread_sched *_lthread_sched_get(int lcore_id);
+struct lthread_sched *_lthread_sched_get(unsigned int lcore_id);
 
 struct lthread_stack *_stack_alloc(void);
 
diff --git a/examples/performance-thread/common/lthread_sched.c b/examples/performance-thread/common/lthread_sched.c
index c64c21ffb..fbda112f4 100644
--- a/examples/performance-thread/common/lthread_sched.c
+++ b/examples/performance-thread/common/lthread_sched.c
@@ -562,11 +562,14 @@ void lthread_run(void)
  * Return the scheduler for this lcore
  *
  */
-struct lthread_sched *_lthread_sched_get(int lcore_id)
+struct lthread_sched *_lthread_sched_get(unsigned int lcore_id)
 {
-	if (lcore_id > LTHREAD_MAX_LCORES)
-		return NULL;
-	return schedcore[lcore_id];
+	struct lthread_sched *res = NULL;
+
+	if (lcore_id < LTHREAD_MAX_LCORES)
+		res = schedcore[lcore_id];
+
+	return res;
 }
 
 /*
@@ -578,10 +581,9 @@ int lthread_set_affinity(unsigned lcoreid)
 	struct lthread *lt = THIS_LTHREAD;
 	struct lthread_sched *dest_sched;
 
-	if (unlikely(lcoreid > LTHREAD_MAX_LCORES))
+	if (unlikely(lcoreid >= LTHREAD_MAX_LCORES))
 		return POSIX_ERRNO(EINVAL);
 
-
 	DIAG_EVENT(lt, LT_DIAG_LTHREAD_AFFINITY, lcoreid, 0);
 
 	dest_sched = schedcore[lcoreid];
-- 
2.11.0



More information about the stable mailing list