patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] ring: fix overflow in memory size calcuation
@ 2021-12-14  3:30 Zhihong Wang
  2021-12-15  8:01 ` Liang Ma
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Zhihong Wang @ 2021-12-14  3:30 UTC (permalink / raw)
  To: konstantin.ananyev, honnappa.nagarahalli, dev; +Cc: Zhihong Wang, stable

Parameters count and esize are both unsigned int, and their product can
legally exceed unsigned int and lead to runtime access violation.

Fixes: cc4b218790f6 ("ring: support configurable element size")
Cc: stable@dpdk.org

Signed-off-by: Zhihong Wang <wangzhihong.wzh@bytedance.com>
---
 lib/ring/rte_ring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index f17bd966be..d1b80597af 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -75,7 +75,7 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count)
 		return -EINVAL;
 	}
 
-	sz = sizeof(struct rte_ring) + count * esize;
+	sz = sizeof(struct rte_ring) + (ssize_t)count * esize;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 	return sz;
 }
-- 
2.11.0


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

* Re: [PATCH] ring: fix overflow in memory size calcuation
  2021-12-14  3:30 [PATCH] ring: fix overflow in memory size calcuation Zhihong Wang
@ 2021-12-15  8:01 ` Liang Ma
  2021-12-15  8:32   ` Morten Brørup
  2021-12-15 13:18 ` Ananyev, Konstantin
  2022-02-05 17:21 ` David Marchand
  2 siblings, 1 reply; 5+ messages in thread
From: Liang Ma @ 2021-12-15  8:01 UTC (permalink / raw)
  To: Zhihong Wang; +Cc: konstantin.ananyev, honnappa.nagarahalli, dev, stable

On Tue, Dec 14, 2021 at 11:30:16AM +0800, Zhihong Wang wrote:
> Parameters count and esize are both unsigned int, and their product can
> legally exceed unsigned int and lead to runtime access violation.
> 
> Fixes: cc4b218790f6 ("ring: support configurable element size")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Zhihong Wang <wangzhihong.wzh@bytedance.com>
> ---
>  lib/ring/rte_ring.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
> index f17bd966be..d1b80597af 100644
> --- a/lib/ring/rte_ring.c
> +++ b/lib/ring/rte_ring.c
> @@ -75,7 +75,7 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count)
>  		return -EINVAL;
>  	}
>  
> -	sz = sizeof(struct rte_ring) + count * esize;
> +	sz = sizeof(struct rte_ring) + (ssize_t)count * esize;
>  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
>  	return sz;
>  }
> -- 
> 2.11.0
>
Reviewed-by Liang Ma <liangma@liangbit.com>

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

* RE: [PATCH] ring: fix overflow in memory size calcuation
  2021-12-15  8:01 ` Liang Ma
@ 2021-12-15  8:32   ` Morten Brørup
  0 siblings, 0 replies; 5+ messages in thread
From: Morten Brørup @ 2021-12-15  8:32 UTC (permalink / raw)
  To: Liang Ma, Zhihong Wang
  Cc: konstantin.ananyev, honnappa.nagarahalli, dev, stable

> From: Liang Ma [mailto:liangma@liangbit.com]
> Sent: Wednesday, 15 December 2021 09.01
> 
> On Tue, Dec 14, 2021 at 11:30:16AM +0800, Zhihong Wang wrote:
> > Parameters count and esize are both unsigned int, and their product
> can
> > legally exceed unsigned int and lead to runtime access violation.
> >
> > Fixes: cc4b218790f6 ("ring: support configurable element size")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Zhihong Wang <wangzhihong.wzh@bytedance.com>
> > ---
> >  lib/ring/rte_ring.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
> > index f17bd966be..d1b80597af 100644
> > --- a/lib/ring/rte_ring.c
> > +++ b/lib/ring/rte_ring.c
> > @@ -75,7 +75,7 @@ rte_ring_get_memsize_elem(unsigned int esize,
> unsigned int count)
> >  		return -EINVAL;
> >  	}
> >
> > -	sz = sizeof(struct rte_ring) + count * esize;
> > +	sz = sizeof(struct rte_ring) + (ssize_t)count * esize;
> >  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> >  	return sz;
> >  }
> > --
> > 2.11.0
> >
> Reviewed-by Liang Ma <liangma@liangbit.com>

I was wondering about the type conversion to signed (instead of unsigned), but sz is ssize_t, so the conversion to ssize_t is correct. Otherwise, sz should be changed from ssize_t to size_t too.

No need for further changes.

Reviewed-by: Morten Brørup <mb@smartsharesystems.com>


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

* RE: [PATCH] ring: fix overflow in memory size calcuation
  2021-12-14  3:30 [PATCH] ring: fix overflow in memory size calcuation Zhihong Wang
  2021-12-15  8:01 ` Liang Ma
@ 2021-12-15 13:18 ` Ananyev, Konstantin
  2022-02-05 17:21 ` David Marchand
  2 siblings, 0 replies; 5+ messages in thread
From: Ananyev, Konstantin @ 2021-12-15 13:18 UTC (permalink / raw)
  To: Zhihong Wang, honnappa.nagarahalli, dev; +Cc: stable



> Parameters count and esize are both unsigned int, and their product can
> legally exceed unsigned int and lead to runtime access violation.
> 
> Fixes: cc4b218790f6 ("ring: support configurable element size")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Zhihong Wang <wangzhihong.wzh@bytedance.com>
> ---
>  lib/ring/rte_ring.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
> index f17bd966be..d1b80597af 100644
> --- a/lib/ring/rte_ring.c
> +++ b/lib/ring/rte_ring.c
> @@ -75,7 +75,7 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count)
>  		return -EINVAL;
>  	}
> 
> -	sz = sizeof(struct rte_ring) + count * esize;
> +	sz = sizeof(struct rte_ring) + (ssize_t)count * esize;
>  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
>  	return sz;
>  }
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 2.11.0


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

* Re: [PATCH] ring: fix overflow in memory size calcuation
  2021-12-14  3:30 [PATCH] ring: fix overflow in memory size calcuation Zhihong Wang
  2021-12-15  8:01 ` Liang Ma
  2021-12-15 13:18 ` Ananyev, Konstantin
@ 2022-02-05 17:21 ` David Marchand
  2 siblings, 0 replies; 5+ messages in thread
From: David Marchand @ 2022-02-05 17:21 UTC (permalink / raw)
  To: Zhihong Wang
  Cc: Ananyev, Konstantin, Honnappa Nagarahalli, dev, dpdk stable,
	liangma, Morten Brørup

On Tue, Dec 14, 2021 at 4:30 AM Zhihong Wang
<wangzhihong.wzh@bytedance.com> wrote:
>
> Parameters count and esize are both unsigned int, and their product can
> legally exceed unsigned int and lead to runtime access violation.
>
> Fixes: cc4b218790f6 ("ring: support configurable element size")
> Cc: stable@dpdk.org
>
> Signed-off-by: Zhihong Wang <wangzhihong.wzh@bytedance.com>

Reviewed-by: Liang Ma <liangma@liangbit.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Applied, thanks.


-- 
David Marchand


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

end of thread, other threads:[~2022-02-05 17:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14  3:30 [PATCH] ring: fix overflow in memory size calcuation Zhihong Wang
2021-12-15  8:01 ` Liang Ma
2021-12-15  8:32   ` Morten Brørup
2021-12-15 13:18 ` Ananyev, Konstantin
2022-02-05 17:21 ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).