patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [PATCH] ethdev: fix secondary process change share memory
@ 2020-01-09  3:14 Fang TongHao
  2020-01-10 15:32 ` [dpdk-stable] [dpdk-dev] " Stephen Hemminger
  0 siblings, 1 reply; 7+ messages in thread
From: Fang TongHao @ 2020-01-09  3:14 UTC (permalink / raw)
  To: thomas, ferruh.yigit, arybchenko
  Cc: dev, stable, cunming.liang, jia.guo, Fang TongHao

Hi all,I am from Sangfor Tech.I found a bug when using DPDK in
multiprocess scenario.The secondary process enters
"rte_eth_dev_pci_copy_info" function when initializing.Then it
sets the value of struct "rte_eth_dev_data.dev_flags" to zero,
but this struct is shared by primary process and secondary
process, and the value change is unexpected by primary process.
This may cause very serious damage.I think
the secondary process should not enter "rte_eth_dev_pci_copy_info"
function or changes the value of struct "rte_eth_dev_data.dev_flags"
in shared memory.
I fixed this bug by adding an if-statement to forbid the secondary
process changing the above-mentioned value.
Thansk, All.

Signed-off-by: Fang TongHao <fangtonghao@sangfor.com.cn>
---
 lib/librte_ethdev/rte_ethdev_pci.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h
index ccdbb46ec..916de8a14 100644
--- a/lib/librte_ethdev/rte_ethdev_pci.h
+++ b/lib/librte_ethdev/rte_ethdev_pci.h
@@ -59,15 +59,16 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 	}
 
 	eth_dev->intr_handle = &pci_dev->intr_handle;
-
-	eth_dev->data->dev_flags = 0;
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
-		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
-		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
-
-	eth_dev->data->kdrv = pci_dev->kdrv;
-	eth_dev->data->numa_node = pci_dev->device.numa_node;
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		eth_dev->data->dev_flags = 0;
+		if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+			eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
+		if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
+			eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
+
+		eth_dev->data->kdrv = pci_dev->kdrv;
+		eth_dev->data->numa_node = pci_dev->device.numa_node;
+	}
 }
 
 static inline int
-- 
2.24.1.windows.2


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] ethdev: fix secondary process change share memory
  2020-01-09  3:14 [dpdk-stable] [PATCH] ethdev: fix secondary process change share memory Fang TongHao
@ 2020-01-10 15:32 ` " Stephen Hemminger
  2020-01-13  3:02   ` 方统浩50450
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2020-01-10 15:32 UTC (permalink / raw)
  To: Fang TongHao
  Cc: thomas, ferruh.yigit, arybchenko, dev, stable, cunming.liang, jia.guo

On Thu,  9 Jan 2020 11:14:25 +0800
Fang TongHao <fangtonghao@sangfor.com.cn> wrote:

> Hi all,I am from Sangfor Tech.I found a bug when using DPDK in
> multiprocess scenario.The secondary process enters
> "rte_eth_dev_pci_copy_info" function when initializing.Then it
> sets the value of struct "rte_eth_dev_data.dev_flags" to zero,
> but this struct is shared by primary process and secondary
> process, and the value change is unexpected by primary process.
> This may cause very serious damage.I think
> the secondary process should not enter "rte_eth_dev_pci_copy_info"
> function or changes the value of struct "rte_eth_dev_data.dev_flags"
> in shared memory.
> I fixed this bug by adding an if-statement to forbid the secondary
> process changing the above-mentioned value.
> Thansk, All.
> 
> Signed-off-by: Fang TongHao <fangtonghao@sangfor.com.cn>

Most of the drivers avoid calling rte_eth_dev_pci_copy_info
in the secondary process, which one are you using?

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] ethdev: fix secondary process change share memory
  2020-01-10 15:32 ` [dpdk-stable] [dpdk-dev] " Stephen Hemminger
@ 2020-01-13  3:02   ` 方统浩50450
  0 siblings, 0 replies; 7+ messages in thread
From: 方统浩50450 @ 2020-01-13  3:02 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: thomas, ferruh.yigit, arybchenko, dev, stable, cunming.liang, jia.guo

secondary process will enter rte_eth_copy_pci_info function when initializing.
rte_eth_dev_pci_copy_info -> rte_eth_copy_pci_info




发件人:Stephen Hemminger <stephen@networkplumber.org>
发送日期:2020-01-10 23:32:15
收件人:Fang TongHao <fangtonghao@sangfor.com.cn>
抄送人:thomas@monjalon.net,ferruh.yigit@intel.com,arybchenko@solarflare.com,dev@dpdk.org,stable@dpdk.org,cunming.liang@intel.com,jia.guo@intel.com
主题:Re: [dpdk-dev] [PATCH] ethdev: fix secondary process change share memory>On Thu,  9 Jan 2020 11:14:25 +0800
>Fang TongHao <fangtonghao@sangfor.com.cn> wrote:
>
>> Hi all,I am from Sangfor Tech.I found a bug when using DPDK in
>> multiprocess scenario.The secondary process enters
>> "rte_eth_dev_pci_copy_info" function when initializing.Then it
>> sets the value of struct "rte_eth_dev_data.dev_flags" to zero,
>> but this struct is shared by primary process and secondary
>> process, and the value change is unexpected by primary process.
>> This may cause very serious damage.I think
>> the secondary process should not enter "rte_eth_dev_pci_copy_info"
>> function or changes the value of struct "rte_eth_dev_data.dev_flags"
>> in shared memory.
>> I fixed this bug by adding an if-statement to forbid the secondary
>> process changing the above-mentioned value.
>> Thansk, All.
>> 
>> Signed-off-by: Fang TongHao <fangtonghao@sangfor.com.cn>
>
>Most of the drivers avoid calling rte_eth_dev_pci_copy_info
>in the secondary process, which one are you using?





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

* Re: [dpdk-stable] [PATCH] ethdev: fix secondary process change share memory
  2020-01-10  7:30 ` Jeff Guo
@ 2020-01-10  7:53   ` 方统浩50450
  0 siblings, 0 replies; 7+ messages in thread
From: 方统浩50450 @ 2020-01-10  7:53 UTC (permalink / raw)
  To: Jeff Guo; +Cc: thomas, ferruh.yigit, arybchenko, cunming.liang, dev, stable

thanks for your correction 
I will rewrite my commit log and send email again


方统浩50450
邮箱:fangtonghao@sangfor.com.cn
签名由 网易邮箱大师 定制


On 01/10/2020 15:30, Jeff Guo wrote:

hi, tonghao


 On 1/9/2020 8:27 PM, Fang TongHao wrote:
 > Hi all,I am from Sangfor Tech.I found a bug when using DPDK in
 > multiprocess scenario.The secondary process enters
 > "rte_eth_dev_pci_copy_info" function when initializing.Then it
 > sets the value of struct "rte_eth_dev_data.dev_flags" to zero,
 > but this struct is shared by primary process and secondary
 > process, and the value change is unexpected by primary process.
 > This may cause very serious damage.I think
 > the secondary process should not enter "rte_eth_dev_pci_copy_info"
 > function or changes the value of struct "rte_eth_dev_data.dev_flags"
 > in shared memory.
 > I fixed this bug by adding an if-statement to forbid the secondary
 > process changing the above-mentioned value.
 > Thansk, All.


 i think the format of commit log should be refined to be more formal
 like as below. what do you think?

 ethdev: XXXXXXXXX

 XXXXXXXX


 > Signed-off-by: Fang TongHao <fangtonghao@sangfor.com.cn>


 if it is a fix, suggest to add the line as "Fixes: XXXXXXXX ("ethdev:
 XXXXXXX") to trace it.


 > ---
 >   lib/librte_ethdev/rte_ethdev_pci.h | 19 ++++++++++---------
 >   1 file changed, 10 insertions(+), 9 deletions(-)
 >
 > diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h
 > index ccdbb46ec..916de8a14 100644
 > --- a/lib/librte_ethdev/rte_ethdev_pci.h
 > +++ b/lib/librte_ethdev/rte_ethdev_pci.h
 > @@ -59,15 +59,16 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 >       }
 >   
 >       eth_dev->intr_handle = &pci_dev->intr_handle;
 > -
 > -    eth_dev->data->dev_flags = 0;
 > -    if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
 > -        eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
 > -    if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
 > -        eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
 > -
 > -    eth_dev->data->kdrv = pci_dev->kdrv;
 > -    eth_dev->data->numa_node = pci_dev->device.numa_node;
 > +    if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 > +        eth_dev->data->dev_flags = 0;
 > +        if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
 > +            eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
 > +        if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
 > +            eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
 > +
 > +        eth_dev->data->kdrv = pci_dev->kdrv;
 > +        eth_dev->data->numa_node = pci_dev->device.numa_node;


 From the change log, you said that "rte_eth_dev_data.dev_flags" should
 not be touched by secondary process, but you don't mention about

 data->kdrv and data->numa_node, could you also explain them in the log
 if they need to process as the same.


 > +    }
 >   }
 >   
 >   static inline int





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

* Re: [dpdk-stable] [PATCH] ethdev: fix secondary process change share memory
  2020-01-09 12:27 [dpdk-stable] " Fang TongHao
@ 2020-01-10  7:30 ` Jeff Guo
  2020-01-10  7:53   ` 方统浩50450
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff Guo @ 2020-01-10  7:30 UTC (permalink / raw)
  To: Fang TongHao, thomas, ferruh.yigit, arybchenko; +Cc: cunming.liang, dev, stable

hi, tonghao


On 1/9/2020 8:27 PM, Fang TongHao wrote:
> Hi all,I am from Sangfor Tech.I found a bug when using DPDK in
> multiprocess scenario.The secondary process enters
> "rte_eth_dev_pci_copy_info" function when initializing.Then it
> sets the value of struct "rte_eth_dev_data.dev_flags" to zero,
> but this struct is shared by primary process and secondary
> process, and the value change is unexpected by primary process.
> This may cause very serious damage.I think
> the secondary process should not enter "rte_eth_dev_pci_copy_info"
> function or changes the value of struct "rte_eth_dev_data.dev_flags"
> in shared memory.
> I fixed this bug by adding an if-statement to forbid the secondary
> process changing the above-mentioned value.
> Thansk, All.


i think the format of commit log should be refined to be more formal 
like as below. what do you think?

ethdev: XXXXXXXXX

XXXXXXXX


> Signed-off-by: Fang TongHao <fangtonghao@sangfor.com.cn>


if it is a fix, suggest to add the line as "Fixes: XXXXXXXX ("ethdev: 
XXXXXXX") to trace it.


> ---
>   lib/librte_ethdev/rte_ethdev_pci.h | 19 ++++++++++---------
>   1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h
> index ccdbb46ec..916de8a14 100644
> --- a/lib/librte_ethdev/rte_ethdev_pci.h
> +++ b/lib/librte_ethdev/rte_ethdev_pci.h
> @@ -59,15 +59,16 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
>   	}
>   
>   	eth_dev->intr_handle = &pci_dev->intr_handle;
> -
> -	eth_dev->data->dev_flags = 0;
> -	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
> -		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
> -	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
> -		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
> -
> -	eth_dev->data->kdrv = pci_dev->kdrv;
> -	eth_dev->data->numa_node = pci_dev->device.numa_node;
> +	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> +		eth_dev->data->dev_flags = 0;
> +		if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
> +			eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
> +		if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
> +			eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
> +
> +		eth_dev->data->kdrv = pci_dev->kdrv;
> +		eth_dev->data->numa_node = pci_dev->device.numa_node;


 From the change log, you said that "rte_eth_dev_data.dev_flags" should 
not be touched by secondary process, but you don't mention about

data->kdrv and data->numa_node, could you also explain them in the log 
if they need to process as the same.


> +	}
>   }
>   
>   static inline int

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

* [dpdk-stable] [PATCH] ethdev: fix secondary process change share memory
@ 2020-01-09 12:27 " Fang TongHao
  2020-01-10  7:30 ` Jeff Guo
  0 siblings, 1 reply; 7+ messages in thread
From: Fang TongHao @ 2020-01-09 12:27 UTC (permalink / raw)
  To: thomas, ferruh.yigit, arybchenko
  Cc: cunming.liang, jia.guo, dev, stable, Fang TongHao

Hi all,I am from Sangfor Tech.I found a bug when using DPDK in
multiprocess scenario.The secondary process enters
"rte_eth_dev_pci_copy_info" function when initializing.Then it
sets the value of struct "rte_eth_dev_data.dev_flags" to zero,
but this struct is shared by primary process and secondary
process, and the value change is unexpected by primary process.
This may cause very serious damage.I think
the secondary process should not enter "rte_eth_dev_pci_copy_info"
function or changes the value of struct "rte_eth_dev_data.dev_flags"
in shared memory.
I fixed this bug by adding an if-statement to forbid the secondary
process changing the above-mentioned value.
Thansk, All.

Signed-off-by: Fang TongHao <fangtonghao@sangfor.com.cn>
---
 lib/librte_ethdev/rte_ethdev_pci.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h
index ccdbb46ec..916de8a14 100644
--- a/lib/librte_ethdev/rte_ethdev_pci.h
+++ b/lib/librte_ethdev/rte_ethdev_pci.h
@@ -59,15 +59,16 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 	}
 
 	eth_dev->intr_handle = &pci_dev->intr_handle;
-
-	eth_dev->data->dev_flags = 0;
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
-		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
-		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
-
-	eth_dev->data->kdrv = pci_dev->kdrv;
-	eth_dev->data->numa_node = pci_dev->device.numa_node;
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		eth_dev->data->dev_flags = 0;
+		if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+			eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
+		if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
+			eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
+
+		eth_dev->data->kdrv = pci_dev->kdrv;
+		eth_dev->data->numa_node = pci_dev->device.numa_node;
+	}
 }
 
 static inline int
-- 
2.24.1.windows.2


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

* [dpdk-stable] [PATCH] ethdev: fix secondary process change share memory
@ 2020-01-09  2:35 Fang TongHao
  0 siblings, 0 replies; 7+ messages in thread
From: Fang TongHao @ 2020-01-09  2:35 UTC (permalink / raw)
  To: dev; +Cc: Fang TongHao, stable

Hi all,I am from Sangfor Tech.I found a bug when using DPDK in
multiprocess scenario.The secondary process enters
"rte_eth_dev_pci_copy_info" function when initializing.Then it
sets the value of struct "rte_eth_dev_data.dev_flags" to zero,
but this struct is shared by primary process and secondary
process, and the value change is unexpected by primary process.
This may cause very serious damage.I think
the secondary process should not enter "rte_eth_dev_pci_copy_info"
function or changes the value of struct "rte_eth_dev_data.dev_flags"
in shared memory.
I fixed this bug by adding an if-statement to forbid the secondary
process changing the above-mentioned value.
Thansk, All.
Cc: stable@dpdk.org

Signed-off-by: Fang TongHao <fangtonghao@sangfor.com.cn>
---
 lib/librte_ethdev/rte_ethdev_pci.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h
index ccdbb46ec..916de8a14 100644
--- a/lib/librte_ethdev/rte_ethdev_pci.h
+++ b/lib/librte_ethdev/rte_ethdev_pci.h
@@ -59,15 +59,16 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 	}
 
 	eth_dev->intr_handle = &pci_dev->intr_handle;
-
-	eth_dev->data->dev_flags = 0;
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
-		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
-		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
-
-	eth_dev->data->kdrv = pci_dev->kdrv;
-	eth_dev->data->numa_node = pci_dev->device.numa_node;
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		eth_dev->data->dev_flags = 0;
+		if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+			eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
+		if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
+			eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
+
+		eth_dev->data->kdrv = pci_dev->kdrv;
+		eth_dev->data->numa_node = pci_dev->device.numa_node;
+	}
 }
 
 static inline int
-- 
2.24.1.windows.2


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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09  3:14 [dpdk-stable] [PATCH] ethdev: fix secondary process change share memory Fang TongHao
2020-01-10 15:32 ` [dpdk-stable] [dpdk-dev] " Stephen Hemminger
2020-01-13  3:02   ` 方统浩50450
  -- strict thread matches above, loose matches on Subject: below --
2020-01-09 12:27 [dpdk-stable] " Fang TongHao
2020-01-10  7:30 ` Jeff Guo
2020-01-10  7:53   ` 方统浩50450
2020-01-09  2:35 Fang TongHao

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/ public-inbox