patches for DPDK stable branches
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Liang Ma" <liangma@liangbit.com>,
	"Zhihong Wang" <wangzhihong.wzh@bytedance.com>
Cc: <konstantin.ananyev@intel.com>, <honnappa.nagarahalli@arm.com>,
	<dev@dpdk.org>, <stable@dpdk.org>
Subject: RE: [PATCH] ring: fix overflow in memory size calcuation
Date: Wed, 15 Dec 2021 09:32:06 +0100	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D86D76@smartserver.smartshare.dk> (raw)
In-Reply-To: <Ybmgwyv4H+g0hCYw@C02GF04TMD6V>

> 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>


  reply	other threads:[~2021-12-15  8:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14  3:30 Zhihong Wang
2021-12-15  8:01 ` Liang Ma
2021-12-15  8:32   ` Morten Brørup [this message]
2021-12-15 13:18 ` Ananyev, Konstantin
2022-02-05 17:21 ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98CBD80474FA8B44BF855DF32C47DC35D86D76@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=dev@dpdk.org \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=liangma@liangbit.com \
    --cc=stable@dpdk.org \
    --cc=wangzhihong.wzh@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).