[dpdk-dev] vfio: fix array bounds check

Message ID 1494584305-36279-1-git-send-email-alejandro.lucero@netronome.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

Alejandro Lucero May 12, 2017, 10:18 a.m. UTC
  Checking against VFIO_MAX_GROUPS goes beyond the maximum array
index which should be (VFIO_MAX_GROUPS - 1).

Fixes: 94c0776b1bad("support hotplug")
Coverity issue: 144555
Coverity issue: 144556
Coverity issue: 144557

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
 lib/librte_eal/linuxapp/eal/eal_vfio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Anatoly Burakov May 12, 2017, 11:04 a.m. UTC | #1
> From: Alejandro Lucero [mailto:alejandro.lucero@netronome.com]
> Sent: Friday, May 12, 2017 11:18 AM
> To: dev@dpdk.org
> Cc: Burakov, Anatoly <anatoly.burakov@intel.com>
> Subject: [PATCH] vfio: fix array bounds check
> 
> Checking against VFIO_MAX_GROUPS goes beyond the maximum array
> index which should be (VFIO_MAX_GROUPS - 1).
> 
> Fixes: 94c0776b1bad("support hotplug")
> Coverity issue: 144555
> Coverity issue: 144556
> Coverity issue: 144557
> 
> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>


Acked-by: Anatoly  Burakov <anatoly.burakov@intel.com>
  
Thomas Monjalon June 5, 2017, 7:01 p.m. UTC | #2
12/05/2017 13:04, Burakov, Anatoly:
> > From: Alejandro Lucero [mailto:alejandro.lucero@netronome.com]
> > 
> > Checking against VFIO_MAX_GROUPS goes beyond the maximum array
> > index which should be (VFIO_MAX_GROUPS - 1).
> > 
> > Fixes: 94c0776b1bad("support hotplug")
> > Coverity issue: 144555
> > Coverity issue: 144556
> > Coverity issue: 144557
> > 
> > Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
> 
> Acked-by: Anatoly  Burakov <anatoly.burakov@intel.com>

Applied, thanks

Anatoly, you are often inserting two spaces between your first name
and last name. Recurring typo?
  
Anatoly Burakov June 8, 2017, 8:53 a.m. UTC | #3
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Monday, June 5, 2017 8:01 PM
> To: Alejandro Lucero <alejandro.lucero@netronome.com>
> Cc: dev@dpdk.org; Burakov, Anatoly <anatoly.burakov@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] vfio: fix array bounds check
> 
> 12/05/2017 13:04, Burakov, Anatoly:
> > > From: Alejandro Lucero [mailto:alejandro.lucero@netronome.com]
> > >
> > > Checking against VFIO_MAX_GROUPS goes beyond the maximum array
> index
> > > which should be (VFIO_MAX_GROUPS - 1).
> > >
> > > Fixes: 94c0776b1bad("support hotplug") Coverity issue: 144555
> > > Coverity issue: 144556 Coverity issue: 144557
> > >
> > > Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
> >
> > Acked-by: Anatoly  Burakov <anatoly.burakov@intel.com>
> 
> Applied, thanks
> 
> Anatoly, you are often inserting two spaces between your first name and last
> name. Recurring typo?

Probably git misconfiguration. Thanks!
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c
index 5486dca..4816afc 100644
--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
@@ -189,7 +189,7 @@ 
 	int i;
 
 	i = get_vfio_group_idx(vfio_group_fd);
-	if (i < 0 || i > VFIO_MAX_GROUPS)
+	if (i < 0 || i > (VFIO_MAX_GROUPS - 1))
 		RTE_LOG(ERR, EAL, "  wrong vfio_group index (%d)\n", i);
 	else
 		vfio_cfg.vfio_groups[i].devices++;
@@ -201,7 +201,7 @@ 
 	int i;
 
 	i = get_vfio_group_idx(vfio_group_fd);
-	if (i < 0 || i > VFIO_MAX_GROUPS)
+	if (i < 0 || i > (VFIO_MAX_GROUPS - 1))
 		RTE_LOG(ERR, EAL, "  wrong vfio_group index (%d)\n", i);
 	else
 		vfio_cfg.vfio_groups[i].devices--;
@@ -213,7 +213,7 @@ 
 	int i;
 
 	i = get_vfio_group_idx(vfio_group_fd);
-	if (i < 0 || i > VFIO_MAX_GROUPS) {
+	if (i < 0 || i > (VFIO_MAX_GROUPS - 1)) {
 		RTE_LOG(ERR, EAL, "  wrong vfio_group index (%d)\n", i);
 		return -1;
 	}