[dpdk-dev] examples/performance-thread: fix out-of-bounds read

Message ID 1505894737-25596-1-git-send-email-slawomirx.mrozowicz@intel.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Slawomir Mrozowicz Sept. 20, 2017, 8:05 a.m. UTC
  Overrunning array schedcore of 128 8-byte elements at element index 128
using index lcoreid.
Fixed by correct check index lcoreid condition.

Coverity issue: 143461
Fixes: 116819b9ed0d ("examples/performance-thread: add lthread subsystem")
Cc: ian.betts@intel.com
Cc: stable@dpdk.org

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
---
 examples/performance-thread/common/lthread_sched.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Michal Jastrzebski Oct. 11, 2017, 1:55 p.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Slawomir
> Mrozowicz
> Sent: Wednesday, September 20, 2017 10:06 AM
> To: Mcnamara, John <john.mcnamara@intel.com>
> Cc: dev@dpdk.org; Mrozowicz, SlawomirX
> <slawomirx.mrozowicz@intel.com>; ian.betts@intel.com; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] examples/performance-thread: fix out-of-
> bounds read
> 
> Overrunning array schedcore of 128 8-byte elements at element index 128
> using index lcoreid.
> Fixed by correct check index lcoreid condition.
> 
> Coverity issue: 143461
> Fixes: 116819b9ed0d ("examples/performance-thread: add lthread
> subsystem")
> Cc: ian.betts@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
> ---
>  examples/performance-thread/common/lthread_sched.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/examples/performance-thread/common/lthread_sched.c
> b/examples/performance-thread/common/lthread_sched.c
> index 98291478e..138a87d32 100644
> --- a/examples/performance-thread/common/lthread_sched.c
> +++ b/examples/performance-thread/common/lthread_sched.c
> @@ -578,10 +578,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

Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
  
Thomas Monjalon Oct. 13, 2017, 11:19 p.m. UTC | #2
> > Overrunning array schedcore of 128 8-byte elements at element index 128
> > using index lcoreid.
> > Fixed by correct check index lcoreid condition.
> > 
> > Coverity issue: 143461
> > Fixes: 116819b9ed0d ("examples/performance-thread: add lthread
> > subsystem")
> > Cc: ian.betts@intel.com
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
> 
> Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>

Applied, thanks
  

Patch

diff --git a/examples/performance-thread/common/lthread_sched.c b/examples/performance-thread/common/lthread_sched.c
index 98291478e..138a87d32 100644
--- a/examples/performance-thread/common/lthread_sched.c
+++ b/examples/performance-thread/common/lthread_sched.c
@@ -578,10 +578,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];