DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: Niall Meade <niall.meade@intel.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	Roman Zhukov <roman.zhukov@arknetworks.am>
Cc: dev@dpdk.org
Subject: Re: [PATCH v1] ethdev: fix int overflow in descriptor count logic
Date: Mon, 23 Sep 2024 12:52:01 +0300	[thread overview]
Message-ID: <e221651a-defd-4a5c-8164-d541fe65a8bf@oktetlabs.ru> (raw)
In-Reply-To: <20240923092601.728817-1-niall.meade@intel.com>

On 9/23/24 12:26, Niall Meade wrote:
> Addressed a specific overflow issue in the eth_dev_adjust_nb_desc()
> function where the uint16_t variable nb_desc would overflow when its
> value was greater than (2^16 - nb_align). This overflow caused nb_desc
> to incorrectly wrap around between 0 and nb_align-1, leading to the
> function setting nb_desc to nb_min instead of the expected nb_max.
> 
> The resolution involves upcasting nb_desc to a uint32_t before the
> RTE_ALIGN_CEIL macro is applied. This change ensures that the subsequent
> call to RTE_ALIGN_FLOOR(nb_desc + (nb_align - 1), nb_align) does not
> result in an overflow, as it would when nb_desc is a uint16_t. By using
> a uint32_t for these operations, the correct behavior is maintained
> without the risk of overflow.
> 
> Fixes: 0f67fc3baeb9 ("ethdev: add function to adjust number of descriptors")
> 
> Signed-off-by: Niall Meade <niall.meade@intel.com>

Thanks a lot for the fix.

Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>


  reply	other threads:[~2024-09-23  9:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-23  9:26 Niall Meade
2024-09-23  9:52 ` Andrew Rybchenko [this message]
2024-09-25 23:16 ` Ferruh Yigit
2024-09-26 14:03   ` Meade, Niall
2024-09-26 23:51     ` Ferruh Yigit
2024-09-27 10:46       ` Meade, Niall
2024-09-27 21:39         ` Ferruh Yigit

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=e221651a-defd-4a5c-8164-d541fe65a8bf@oktetlabs.ru \
    --to=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=niall.meade@intel.com \
    --cc=roman.zhukov@arknetworks.am \
    --cc=thomas@monjalon.net \
    /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).