patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] bitmap: fix buffer overrun in bitmap init function
@ 2021-06-02  9:06 Andrew Rybchenko
  2021-06-02  9:47 ` [dpdk-stable] [dpdk-dev] " Andrew Rybchenko
  2021-06-02  9:49 ` [dpdk-stable] [PATCH v2] " Andrew Rybchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew Rybchenko @ 2021-06-02  9:06 UTC (permalink / raw)
  To: Cristian Dumitrescu; +Cc: dev, Ivan Ilchenko, stable, Andy Moreton

From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>

Bitmap initialization function is allowed to memset
caller-provided buffer with number of bytes exceeded
this buffer size. This happens due to wrong comparision
sign between buffer size and number of bytes required
to initialize bitmap.

Fixes: 602c9ca33a4 ("sched: bitmap is now dynamically allocated")
Cc: stable@dpdk.org

Reported-by: Andy Moreton <amoreton@xilinx.com>
Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 lib/eal/include/rte_bitmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/eal/include/rte_bitmap.h b/lib/eal/include/rte_bitmap.h
index 9e2b8f2cbf..870aecc594 100644
--- a/lib/eal/include/rte_bitmap.h
+++ b/lib/eal/include/rte_bitmap.h
@@ -185,7 +185,7 @@ rte_bitmap_init(uint32_t n_bits, uint8_t *mem, uint32_t mem_size)
 	size = __rte_bitmap_get_memory_footprint(n_bits,
 		&array1_byte_offset, &array1_slabs,
 		&array2_byte_offset, &array2_slabs);
-	if (size < mem_size) {
+	if (size > mem_size) {
 		return NULL;
 	}
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] bitmap: fix buffer overrun in bitmap init function
  2021-06-02  9:06 [dpdk-stable] [PATCH] bitmap: fix buffer overrun in bitmap init function Andrew Rybchenko
@ 2021-06-02  9:47 ` Andrew Rybchenko
  2021-06-02  9:49 ` [dpdk-stable] [PATCH v2] " Andrew Rybchenko
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Rybchenko @ 2021-06-02  9:47 UTC (permalink / raw)
  To: Cristian Dumitrescu; +Cc: dev, Ivan Ilchenko, stable, Andy Moreton

On 6/2/21 12:06 PM, Andrew Rybchenko wrote:
> From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> 
> Bitmap initialization function is allowed to memset
> caller-provided buffer with number of bytes exceeded
> this buffer size. This happens due to wrong comparision
> sign between buffer size and number of bytes required
> to initialize bitmap.
> 
> Fixes: 602c9ca33a4 ("sched: bitmap is now dynamically allocated")
> Cc: stable@dpdk.org
> 
> Reported-by: Andy Moreton <amoreton@xilinx.com>
> Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
> ---
>  lib/eal/include/rte_bitmap.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/eal/include/rte_bitmap.h b/lib/eal/include/rte_bitmap.h
> index 9e2b8f2cbf..870aecc594 100644
> --- a/lib/eal/include/rte_bitmap.h
> +++ b/lib/eal/include/rte_bitmap.h
> @@ -185,7 +185,7 @@ rte_bitmap_init(uint32_t n_bits, uint8_t *mem, uint32_t mem_size)
>  	size = __rte_bitmap_get_memory_footprint(n_bits,
>  		&array1_byte_offset, &array1_slabs,
>  		&array2_byte_offset, &array2_slabs);
> -	if (size < mem_size) {
> +	if (size > mem_size) {
>  		return NULL;
>  	}
>  
> 

Self-NACK, will fix spelling in v2 and remove curly brackets.
Strictly speaking it is out of scope of the patch, but nice
cleanup on the way.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-stable] [PATCH v2] bitmap: fix buffer overrun in bitmap init function
  2021-06-02  9:06 [dpdk-stable] [PATCH] bitmap: fix buffer overrun in bitmap init function Andrew Rybchenko
  2021-06-02  9:47 ` [dpdk-stable] [dpdk-dev] " Andrew Rybchenko
@ 2021-06-02  9:49 ` Andrew Rybchenko
  2021-06-08 10:25   ` Dumitrescu, Cristian
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Rybchenko @ 2021-06-02  9:49 UTC (permalink / raw)
  To: Cristian Dumitrescu; +Cc: dev, Ivan Ilchenko, stable, Andy Moreton

From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>

Bitmap initialization function is allowed to memset()
caller-provided buffer with number of bytes exceeded
this buffer size. This happens due to wrong comparison
sign between buffer size and number of bytes required
to initialize bitmap.

Fixes: 602c9ca33a4 ("sched: bitmap is now dynamically allocated")
Cc: stable@dpdk.org

Reported-by: Andy Moreton <amoreton@xilinx.com>
Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 lib/eal/include/rte_bitmap.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/eal/include/rte_bitmap.h b/lib/eal/include/rte_bitmap.h
index 9e2b8f2cbf..e4623bb176 100644
--- a/lib/eal/include/rte_bitmap.h
+++ b/lib/eal/include/rte_bitmap.h
@@ -185,9 +185,8 @@ rte_bitmap_init(uint32_t n_bits, uint8_t *mem, uint32_t mem_size)
 	size = __rte_bitmap_get_memory_footprint(n_bits,
 		&array1_byte_offset, &array1_slabs,
 		&array2_byte_offset, &array2_slabs);
-	if (size < mem_size) {
+	if (size > mem_size)
 		return NULL;
-	}
 
 	/* Setup bitmap */
 	memset(mem, 0, size);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [PATCH v2] bitmap: fix buffer overrun in bitmap init function
  2021-06-02  9:49 ` [dpdk-stable] [PATCH v2] " Andrew Rybchenko
@ 2021-06-08 10:25   ` Dumitrescu, Cristian
  2021-06-11  9:13     ` David Marchand
  0 siblings, 1 reply; 5+ messages in thread
From: Dumitrescu, Cristian @ 2021-06-08 10:25 UTC (permalink / raw)
  To: Andrew Rybchenko; +Cc: dev, Ivan Ilchenko, stable, Andy Moreton



> -----Original Message-----
> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Sent: Wednesday, June 2, 2021 10:49 AM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org; Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>;
> stable@dpdk.org; Andy Moreton <amoreton@xilinx.com>
> Subject: [PATCH v2] bitmap: fix buffer overrun in bitmap init function
> 
> From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> 
> Bitmap initialization function is allowed to memset()
> caller-provided buffer with number of bytes exceeded
> this buffer size. This happens due to wrong comparison
> sign between buffer size and number of bytes required
> to initialize bitmap.
> 
> Fixes: 602c9ca33a4 ("sched: bitmap is now dynamically allocated")
> Cc: stable@dpdk.org
> 
> Reported-by: Andy Moreton <amoreton@xilinx.com>
> Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> ---
>  lib/eal/include/rte_bitmap.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/lib/eal/include/rte_bitmap.h b/lib/eal/include/rte_bitmap.h
> index 9e2b8f2cbf..e4623bb176 100644
> --- a/lib/eal/include/rte_bitmap.h
> +++ b/lib/eal/include/rte_bitmap.h
> @@ -185,9 +185,8 @@ rte_bitmap_init(uint32_t n_bits, uint8_t *mem,
> uint32_t mem_size)
>  	size = __rte_bitmap_get_memory_footprint(n_bits,
>  		&array1_byte_offset, &array1_slabs,
>  		&array2_byte_offset, &array2_slabs);
> -	if (size < mem_size) {
> +	if (size > mem_size)
>  		return NULL;
> -	}
> 
>  	/* Setup bitmap */
>  	memset(mem, 0, size);
> --
> 2.30.2

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [PATCH v2] bitmap: fix buffer overrun in bitmap init function
  2021-06-08 10:25   ` Dumitrescu, Cristian
@ 2021-06-11  9:13     ` David Marchand
  0 siblings, 0 replies; 5+ messages in thread
From: David Marchand @ 2021-06-11  9:13 UTC (permalink / raw)
  To: Andrew Rybchenko
  Cc: dev, Ivan Ilchenko, stable, Andy Moreton, Dumitrescu, Cristian

On Tue, Jun 8, 2021 at 12:27 PM Dumitrescu, Cristian
<cristian.dumitrescu@intel.com> wrote:
> > Bitmap initialization function is allowed to memset()
> > caller-provided buffer with number of bytes exceeded
> > this buffer size. This happens due to wrong comparison
> > sign between buffer size and number of bytes required
> > to initialize bitmap.
> >
> > Fixes: 602c9ca33a4 ("sched: bitmap is now dynamically allocated")
> > Cc: stable@dpdk.org
> >
> > Reported-by: Andy Moreton <amoreton@xilinx.com>
> > Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
> > Reviewed-by: Andy Moreton <amoreton@xilinx.com>
> > Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-11  9:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02  9:06 [dpdk-stable] [PATCH] bitmap: fix buffer overrun in bitmap init function Andrew Rybchenko
2021-06-02  9:47 ` [dpdk-stable] [dpdk-dev] " Andrew Rybchenko
2021-06-02  9:49 ` [dpdk-stable] [PATCH v2] " Andrew Rybchenko
2021-06-08 10:25   ` Dumitrescu, Cristian
2021-06-11  9:13     ` David Marchand

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git