DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal/linux: fix multi-process cannot work
@ 2017-03-16 16:28 Jianfeng Tan
  2017-03-29 15:19 ` Sergio Gonzalez Monroy
  0 siblings, 1 reply; 3+ messages in thread
From: Jianfeng Tan @ 2017-03-16 16:28 UTC (permalink / raw)
  To: dev; +Cc: sergio.gonzalez.monroy, benjamin.walker, Jianfeng Tan, stable

When binding with vfio-pci, secondary process cannot be started with
an error message:

    cannot find TAILQ entry for PCI device.

It's due to: struct rte_pci_addr is padded with 1 byte for alignment
by compiler. Then below comparison in commit 2f4adfad0a69
("vfio: add multiprocess support") will fail if the last byte is not
initialized.

    memcmp(&vfio_res->pci_addr, &dev->addr, sizeof(dev->addr)

And commit cdc242f260e7 ("eal/linux: support running as unprivileged user")
just triggers this bug by using a stack un-initialized variable.

The fix is to use rte_eal_compare_pci_addr() for pci addr comparison.

Fixes: 2f4adfad0a69 ("vfio: add multiprocess support")
Fixes: cdc242f260e7 ("eal/linux: support running as unprivileged user")
CC: stable@dpdk.org

Reported-by: Rutkowski, Pawel <pawelx.rutkowski@intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index 5f478c5..7d8b9fb 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -355,7 +355,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 	} else {
 		/* if we're in a secondary process, just find our tailq entry */
 		TAILQ_FOREACH(vfio_res, vfio_res_list, next) {
-			if (memcmp(&vfio_res->pci_addr, &dev->addr, sizeof(dev->addr)))
+			if (rte_eal_compare_pci_addr(&vfio_res->pci_addr,
+						     &dev->addr))
 				continue;
 			break;
 		}
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH] eal/linux: fix multi-process cannot work
  2017-03-16 16:28 [dpdk-dev] [PATCH] eal/linux: fix multi-process cannot work Jianfeng Tan
@ 2017-03-29 15:19 ` Sergio Gonzalez Monroy
  2017-04-04  9:58   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Sergio Gonzalez Monroy @ 2017-03-29 15:19 UTC (permalink / raw)
  To: Jianfeng Tan, dev; +Cc: benjamin.walker, stable

On 16/03/2017 16:28, Jianfeng Tan wrote:
> When binding with vfio-pci, secondary process cannot be started with
> an error message:
>
>      cannot find TAILQ entry for PCI device.
>
> It's due to: struct rte_pci_addr is padded with 1 byte for alignment
> by compiler. Then below comparison in commit 2f4adfad0a69
> ("vfio: add multiprocess support") will fail if the last byte is not
> initialized.
>
>      memcmp(&vfio_res->pci_addr, &dev->addr, sizeof(dev->addr)
>
> And commit cdc242f260e7 ("eal/linux: support running as unprivileged user")
> just triggers this bug by using a stack un-initialized variable.
>
> The fix is to use rte_eal_compare_pci_addr() for pci addr comparison.
>
> Fixes: 2f4adfad0a69 ("vfio: add multiprocess support")
> Fixes: cdc242f260e7 ("eal/linux: support running as unprivileged user")
> CC: stable@dpdk.org
>
> Reported-by: Rutkowski, Pawel <pawelx.rutkowski@intel.com>
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---
>   lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> index 5f478c5..7d8b9fb 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> @@ -355,7 +355,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
>   	} else {
>   		/* if we're in a secondary process, just find our tailq entry */
>   		TAILQ_FOREACH(vfio_res, vfio_res_list, next) {
> -			if (memcmp(&vfio_res->pci_addr, &dev->addr, sizeof(dev->addr)))
> +			if (rte_eal_compare_pci_addr(&vfio_res->pci_addr,
> +						     &dev->addr))
>   				continue;
>   			break;
>   		}


Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>

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

* Re: [dpdk-dev] [PATCH] eal/linux: fix multi-process cannot work
  2017-03-29 15:19 ` Sergio Gonzalez Monroy
@ 2017-04-04  9:58   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2017-04-04  9:58 UTC (permalink / raw)
  To: Jianfeng Tan; +Cc: dev, Sergio Gonzalez Monroy, benjamin.walker, stable

2017-03-29 16:19, Sergio Gonzalez Monroy:
> On 16/03/2017 16:28, Jianfeng Tan wrote:
> > When binding with vfio-pci, secondary process cannot be started with
> > an error message:
> >
> >      cannot find TAILQ entry for PCI device.
> >
> > It's due to: struct rte_pci_addr is padded with 1 byte for alignment
> > by compiler. Then below comparison in commit 2f4adfad0a69
> > ("vfio: add multiprocess support") will fail if the last byte is not
> > initialized.
> >
> >      memcmp(&vfio_res->pci_addr, &dev->addr, sizeof(dev->addr)
> >
> > And commit cdc242f260e7 ("eal/linux: support running as unprivileged user")
> > just triggers this bug by using a stack un-initialized variable.
> >
> > The fix is to use rte_eal_compare_pci_addr() for pci addr comparison.
> >
> > Fixes: 2f4adfad0a69 ("vfio: add multiprocess support")
> > Fixes: cdc242f260e7 ("eal/linux: support running as unprivileged user")
> > CC: stable@dpdk.org
> >
> > Reported-by: Rutkowski, Pawel <pawelx.rutkowski@intel.com>
> > Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> 
> Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>

Applied, thanks

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

end of thread, other threads:[~2017-04-04  9:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 16:28 [dpdk-dev] [PATCH] eal/linux: fix multi-process cannot work Jianfeng Tan
2017-03-29 15:19 ` Sergio Gonzalez Monroy
2017-04-04  9:58   ` Thomas Monjalon

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