DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@amd.com>
To: "Power, Ciara" <ciara.power@intel.com>,
	"Sivaramakrishnan, VenkatX" <venkatx.sivaramakrishnan@intel.com>,
	Igor Russkikh <irusskikh@marvell.com>,
	Selwin Sebastian <selwin.sebastian@amd.com>,
	Ajit Khaparde <ajit.khaparde@broadcom.com>,
	Somnath Kotur <somnath.kotur@broadcom.com>,
	Nithin Dabilpuram <ndabilpuram@marvell.com>,
	Kiran Kumar K <kirankumark@marvell.com>,
	Sunil Kumar Kori <skori@marvell.com>,
	Satha Rao <skoteshwar@marvell.com>,
	"Zhang, Yuying" <yuying.zhang@intel.com>,
	"Xing, Beilei" <beilei.xing@intel.com>,
	Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>,
	Hemant Agrawal <hemant.agrawal@nxp.com>,
	Sachin Saxena <sachin.saxena@nxp.com>,
	"Su, Simei" <simei.su@intel.com>,
	"Wu, Wenjun1" <wenjun1.wu@intel.com>,
	Gagandeep Singh <g.singh@nxp.com>,
	John Daley <johndale@cisco.com>,
	Hyong Youb Kim <hyonkim@cisco.com>, Gaetan Rivet <grive@u256.net>,
	"Zhang, Qi Z" <qi.z.zhang@intel.com>,
	"Wang, Xiao W" <xiao.w.wang@intel.com>,
	Jie Hai <haijie1@huawei.com>,
	Yisen Zhuang <yisen.zhuang@huawei.com>,
	"Wu, Jingjing" <jingjing.wu@intel.com>,
	"Yang, Qiming" <qiming.yang@intel.com>,
	"Guo, Junfeng" <junfeng.guo@intel.com>,
	Andrew Boyer <andrew.boyer@amd.com>,
	Long Li <longli@microsoft.com>, Matan Azrad <matan@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Dariusz Sosnowski <dsosnowski@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>,
	Chaoyong He <chaoyong.he@corigine.com>,
	Jiawen Wu <jiawenwu@trustnetic.com>,
	Harman Kalra <hkalra@marvell.com>,
	Devendra Singh Rawat <dsinghrawat@marvell.com>,
	Alok Prasad <palok@marvell.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Jerin Jacob <jerinj@marvell.com>,
	Maciej Czekaj <mczekaj@marvell.com>,
	Jian Wang <jianwang@trustnetic.com>,
	"Behrens, Jochen" <jbehrens@vmware.com>,
	Thomas Monjalon <thomas@monjalon.net>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [PATCH v5 2/2] drivers/net: return number of types in get supported types
Date: Tue, 23 Jan 2024 15:12:35 +0000	[thread overview]
Message-ID: <a9357d1e-560a-44ac-8ebd-d96856fae28c@amd.com> (raw)
In-Reply-To: <591812fb-e73d-4e0a-9e6d-eccd549d0b81@amd.com>

On 1/23/2024 2:59 PM, Ferruh Yigit wrote:
> On 1/23/2024 12:07 PM, Power, Ciara wrote:
>> Hi Ferruh,
>>
>>> -----Original Message-----
>>> From: Ferruh Yigit <ferruh.yigit@amd.com>
>>> Sent: Friday, January 19, 2024 2:51 PM
>>> To: Sivaramakrishnan, VenkatX <venkatx.sivaramakrishnan@intel.com>; Igor
>>> Russkikh <irusskikh@marvell.com>; Selwin Sebastian
>>> <selwin.sebastian@amd.com>; Ajit Khaparde
>>> <ajit.khaparde@broadcom.com>; Somnath Kotur
>>> <somnath.kotur@broadcom.com>; Nithin Dabilpuram
>>> <ndabilpuram@marvell.com>; Kiran Kumar K <kirankumark@marvell.com>;
>>> Sunil Kumar Kori <skori@marvell.com>; Satha Rao
>>> <skoteshwar@marvell.com>; Zhang, Yuying <yuying.zhang@intel.com>; Xing,
>>> Beilei <beilei.xing@intel.com>; Rahul Lakkireddy
>>> <rahul.lakkireddy@chelsio.com>; Hemant Agrawal
>>> <hemant.agrawal@nxp.com>; Sachin Saxena <sachin.saxena@nxp.com>; Su,
>>> Simei <simei.su@intel.com>; Wu, Wenjun1 <wenjun1.wu@intel.com>;
>>> Gagandeep Singh <g.singh@nxp.com>; John Daley <johndale@cisco.com>;
>>> Hyong Youb Kim <hyonkim@cisco.com>; Gaetan Rivet <grive@u256.net>;
>>> Zhang, Qi Z <qi.z.zhang@intel.com>; Wang, Xiao W <xiao.w.wang@intel.com>;
>>> Jie Hai <haijie1@huawei.com>; Yisen Zhuang <yisen.zhuang@huawei.com>;
>>> Wu, Jingjing <jingjing.wu@intel.com>; Yang, Qiming
>>> <qiming.yang@intel.com>; Guo, Junfeng <junfeng.guo@intel.com>; Andrew
>>> Boyer <andrew.boyer@amd.com>; Long Li <longli@microsoft.com>; Matan
>>> Azrad <matan@nvidia.com>; Viacheslav Ovsiienko <viacheslavo@nvidia.com>;
>>> Dariusz Sosnowski <dsosnowski@nvidia.com>; Ori Kam <orika@nvidia.com>;
>>> Suanming Mou <suanmingm@nvidia.com>; Chaoyong He
>>> <chaoyong.he@corigine.com>; Jiawen Wu <jiawenwu@trustnetic.com>;
>>> Harman Kalra <hkalra@marvell.com>; Devendra Singh Rawat
>>> <dsinghrawat@marvell.com>; Alok Prasad <palok@marvell.com>; Andrew
>>> Rybchenko <andrew.rybchenko@oktetlabs.ru>; Jerin Jacob
>>> <jerinj@marvell.com>; Maciej Czekaj <mczekaj@marvell.com>; Jian Wang
>>> <jianwang@trustnetic.com>; Behrens, Jochen <jbehrens@vmware.com>;
>>> Thomas Monjalon <thomas@monjalon.net>
>>> Cc: dev@dpdk.org; Power, Ciara <ciara.power@intel.com>
>>> Subject: Re: [PATCH v5 2/2] drivers/net: return number of types in get
>>> supported types
>>>
>>> On 1/18/2024 12:07 PM, Sivaramakrishnan Venkat wrote:
>>>> Missing "RTE_PTYPE_UNKNOWN" ptype causes buffer overflow.
>>>> Enhance code such that the dev_supported_ptypes_get() function pointer
>>>> now returns  the number of elements to eliminate the need for
>>>> "RTE_PTYPE_UNKNOWN" as the last item.
>>>>
>>>> Signed-off-by: Sivaramakrishnan Venkat
>>>> <venkatx.sivaramakrishnan@intel.com>
>>>>
>>>> --
>>>>   v5:
>>>>      - modified commit message.
>>>>      - tidied formatting of code.
>>>>      - added doxygen comment.
>>>>   v4:
>>>>      - split into two patches, one for backporting and another one for
>>>>        upstream rework.
>>>>   v3:
>>>>      - reworked the function to return number of elements and remove the
>>>>        need for RTE_PTYPE_UNKNOWN in list.
>>>>   v2:
>>>>      - extended fix for multiple drivers.
>>>> ---
>>>
>>> <...>
>>>
>>>>  59 files changed, 188 insertions(+), 141 deletions(-)
>>>>
>>>
>>> Some driver still have the flag:
>>> - drivers/net/mvneta/mvneta_ethdev.c
>>> - drivers/net/mvpp2/mrvl_ethdev.c
>>> - pfe
>>> - dpaa
>>> - drivers/net/thunderx/nicvf_ethdev.c
>>> - drivers/net/nfp/nfp_net_common.c
>>>
>>> Above seems the ones updated in previous patch, flags added in previous
>>> patch should be removed in this one.
>>>
>>>
>>> And following seems missed and still has the flag:
>>>
>>> - drivers/net/ngbe/ngbe_ptypes.c
>>>
>>> <...>
>>>
>>>> @@ -3971,9 +3975,6 @@ rte_eth_dev_set_ptypes(uint16_t port_id,
>>> uint32_t ptype_mask,
>>>>  		}
>>>>  	}
>>>>
>>>> -	if (set_ptypes != NULL && j < num)
>>>> -		set_ptypes[j] = RTE_PTYPE_UNKNOWN;
>>>> -
>>>>
>>>
>>> This change is new in this version and not mentioned in the changelog.
>>>
>>> 'rte_eth_dev_set_ptypes()' returns 'set_ptypes' that terminated with
>>> 'RTE_PTYPE_UNKNOWN', this is how that API works.
>>> Why changing it in this patch?
>>
>> Apologies, yes, we missed this in the changelog.
>>
>> For the change itself, if we are removing the need for RTE_PTYPE_UNKNOWN in the supported ptypes lists to mark the last element, do we still need to add it here when setting ptypes list?
>> Maybe a misunderstanding on my part - I thought it would be the same for both cases.
>>
>>
> 
> They are two different APIs, and 'rte_eth_dev_set_ptypes()' returns
> ptypes to user that will be terminated by RTE_PTYPE_UNKNOWN, so to not
> break the user code we can't change it.
> 

A little more details if helps:
'rte_eth_dev_get_supported_ptypes()', fills the '*ptypes' and function
return value is number of elements in the '*ptypes' array. There is no
requirement that last element of '*ptypes' will be 'RTE_PTYPE_UNKNOWN',
and if you check the current implementation, it is not.

'rte_eth_dev_set_ptypes()', fills the '*set_ptypes' array and function
return value is function success status. User can deduce the size of
'*set_ptypes' by 'RTE_PTYPE_UNKNOWN' marker at the end of the array.
Requirement is last element should be 'RTE_PTYPE_UNKNOWN', and this
documented in API.

We are preserving above API behavior and only changing ethdev - driver
interface.




  reply	other threads:[~2024-01-23 15:12 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12 14:37 [PATCH v1] net/tap: fix buffer overflow for ptypes list Sivaramakrishnan Venkat
2023-12-12 15:23 ` Ferruh Yigit
2023-12-15 13:38 ` [PATCH v2] " Sivaramakrishnan Venkat
2023-12-15 13:52   ` Ferruh Yigit
2023-12-15 13:55     ` Sivaramakrishnan, VenkatX
2023-12-15 17:21       ` Ferruh Yigit
2023-12-21 18:40 ` [PATCH v3] ethdev: fix getting supported " Sivaramakrishnan Venkat
2023-12-21 21:03   ` Tyler Retzlaff
2023-12-22  8:21   ` David Marchand
2024-01-04 17:51   ` [dpdk-dev v4 2/2] net/tap: fix buffer overflow for " Sivaramakrishnan Venkat
2024-01-04 17:51     ` [dpdk-dev v4 1/2] net/tap: fix buffer overflow for ptypes list through updation of last element Sivaramakrishnan Venkat
2024-01-11 15:11       ` Ferruh Yigit
2024-01-04 17:51     ` [dpdk-dev v4 2/2] net/tap: fix buffer overflow for ptypes list through driver API update Sivaramakrishnan Venkat
2024-01-11 15:12       ` Ferruh Yigit
2024-01-11 16:29       ` Andrew Rybchenko
2024-01-18 12:07 ` [PATCH v5 1/2] drivers/net: fix buffer overflow for ptypes list Sivaramakrishnan Venkat
2024-01-18 12:07   ` [PATCH v5 2/2] drivers/net: return number of types in get supported types Sivaramakrishnan Venkat
2024-01-19 14:51     ` Ferruh Yigit
2024-01-23 12:07       ` Power, Ciara
2024-01-23 14:59         ` Ferruh Yigit
2024-01-23 15:12           ` Ferruh Yigit [this message]
2024-01-23 15:37             ` Power, Ciara
2024-01-19 14:58   ` [PATCH v5 1/2] drivers/net: fix buffer overflow for ptypes list Ferruh Yigit
2024-01-19 17:10     ` Power, Ciara
2024-01-22  9:42       ` Ferruh Yigit
2024-01-22  9:46         ` Power, Ciara
2024-01-22 10:03           ` Ferruh Yigit
2024-01-25 16:07 ` [PATCH v6 " Sivaramakrishnan Venkat
2024-01-25 16:07   ` [PATCH v6 2/2] drivers/net: return number of types in get supported types Sivaramakrishnan Venkat
2024-01-31  3:22     ` Ferruh Yigit
2024-02-01 15:43 ` [PATCH v7 1/2] drivers/net: fix buffer overflow for ptypes list Sivaramakrishnan Venkat
2024-02-01 15:50 ` Sivaramakrishnan Venkat
2024-02-01 15:50   ` [PATCH v7 2/2] drivers/net: return number of types in get supported types Sivaramakrishnan Venkat
2024-02-01 23:02     ` Ferruh Yigit
2024-02-01 22:58   ` [PATCH v7 1/2] drivers/net: fix buffer overflow for ptypes list Ferruh Yigit
2024-02-01 23:29     ` 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=a9357d1e-560a-44ac-8ebd-d96856fae28c@amd.com \
    --to=ferruh.yigit@amd.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=andrew.boyer@amd.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=beilei.xing@intel.com \
    --cc=chaoyong.he@corigine.com \
    --cc=ciara.power@intel.com \
    --cc=dev@dpdk.org \
    --cc=dsinghrawat@marvell.com \
    --cc=dsosnowski@nvidia.com \
    --cc=g.singh@nxp.com \
    --cc=grive@u256.net \
    --cc=haijie1@huawei.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=hkalra@marvell.com \
    --cc=hyonkim@cisco.com \
    --cc=irusskikh@marvell.com \
    --cc=jbehrens@vmware.com \
    --cc=jerinj@marvell.com \
    --cc=jianwang@trustnetic.com \
    --cc=jiawenwu@trustnetic.com \
    --cc=jingjing.wu@intel.com \
    --cc=johndale@cisco.com \
    --cc=junfeng.guo@intel.com \
    --cc=kirankumark@marvell.com \
    --cc=longli@microsoft.com \
    --cc=matan@nvidia.com \
    --cc=mczekaj@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=orika@nvidia.com \
    --cc=palok@marvell.com \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=rahul.lakkireddy@chelsio.com \
    --cc=sachin.saxena@nxp.com \
    --cc=selwin.sebastian@amd.com \
    --cc=simei.su@intel.com \
    --cc=skori@marvell.com \
    --cc=skoteshwar@marvell.com \
    --cc=somnath.kotur@broadcom.com \
    --cc=suanmingm@nvidia.com \
    --cc=thomas@monjalon.net \
    --cc=venkatx.sivaramakrishnan@intel.com \
    --cc=viacheslavo@nvidia.com \
    --cc=wenjun1.wu@intel.com \
    --cc=xiao.w.wang@intel.com \
    --cc=yisen.zhuang@huawei.com \
    --cc=yuying.zhang@intel.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).