From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 68C4845A0E; Mon, 23 Sep 2024 11:52:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E869C402BE; Mon, 23 Sep 2024 11:52:05 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id C2BD440274 for ; Mon, 23 Sep 2024 11:52:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru E4E2344 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1727085122; bh=TBQ+y0AyZl0PuEzAChwfts3bfX2sIhCTQD52hAQu+H0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=YdKjLmto9lihQTTWC08oIJ7GI9/KuO/q8/LFwEfwt/6XPOkSptpeLgSXzC3+PdGB4 kImniA+TTOIIuQ3KcBuwaV1gm8JEDsDSrhGmVxyEmScZ7HGH07kR/QI2twuuJ/bk5q azV0dZ/qxptxxyAhaeFvTdYGk3bfc5cTUuaRaScQ= Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id E4E2344; Mon, 23 Sep 2024 12:52:02 +0300 (MSK) Message-ID: Date: Mon, 23 Sep 2024 12:52:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] ethdev: fix int overflow in descriptor count logic To: Niall Meade , Thomas Monjalon , Ferruh Yigit , Roman Zhukov Cc: dev@dpdk.org References: <20240923092601.728817-1-niall.meade@intel.com> Content-Language: en-US From: Andrew Rybchenko Organization: OKTET Labs In-Reply-To: <20240923092601.728817-1-niall.meade@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Thanks a lot for the fix. Reviewed-by: Andrew Rybchenko