* [PATCH] bus/vdev: vdev_cleanup checks dev->device.driver
@ 2022-10-19 10:48 Zhangfei Gao
2022-10-19 11:39 ` David Marchand
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Zhangfei Gao @ 2022-10-19 10:48 UTC (permalink / raw)
To: Anatoly Burakov, Akhil Goyal, Fan Zhang; +Cc: dev, acc, Zhangfei Gao
The vdev_probe calls driver->probe, which may fail
and dev->device.driver will still be NULL.
In vdev_cleanup, drv = container_of(dev->device.driver) returns !NULL,
then drv->remove will trigger Segmentation fault.
Fix it by checking dev->device.driver first.
Log:
Thread 1 "dpdk-test" received signal SIGSEGV, Segmentation fault.
0x00000000012c484d in vdev_cleanup ()
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
drivers/bus/vdev/vdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index f5b43f1930..fbdaf68380 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -577,6 +577,9 @@ vdev_cleanup(void)
const struct rte_vdev_driver *drv;
int ret = 0;
+ if (dev->device.driver == NULL)
+ continue;
+
drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver);
if (drv == NULL || drv->remove == NULL)
--
2.36.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] bus/vdev: vdev_cleanup checks dev->device.driver
2022-10-19 10:48 [PATCH] bus/vdev: vdev_cleanup checks dev->device.driver Zhangfei Gao
@ 2022-10-19 11:39 ` David Marchand
2022-10-19 13:27 ` Zhangfei Gao
2022-10-19 13:37 ` Zhangfei Gao
2022-10-19 13:56 ` [PATCH v2] " Zhangfei Gao
2022-10-19 14:08 ` [PATCH v2 resend] " Zhangfei Gao
2 siblings, 2 replies; 7+ messages in thread
From: David Marchand @ 2022-10-19 11:39 UTC (permalink / raw)
To: Zhangfei Gao; +Cc: Anatoly Burakov, Akhil Goyal, Fan Zhang, dev, acc
On Wed, Oct 19, 2022 at 12:55 PM Zhangfei Gao <zhangfei.gao@linaro.org> wrote:
>
> The vdev_probe calls driver->probe, which may fail
> and dev->device.driver will still be NULL.
>
> In vdev_cleanup, drv = container_of(dev->device.driver) returns !NULL,
> then drv->remove will trigger Segmentation fault.
> Fix it by checking dev->device.driver first.
>
> Log:
> Thread 1 "dpdk-test" received signal SIGSEGV, Segmentation fault.
> 0x00000000012c484d in vdev_cleanup ()
I suspect you hit this issue when running some crypto autotest.
Can you confirm?
The commit that introduced the issue should be mentionned, with a
Fixes: tag, like:
Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
>
> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
> ---
> drivers/bus/vdev/vdev.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
> index f5b43f1930..fbdaf68380 100644
> --- a/drivers/bus/vdev/vdev.c
> +++ b/drivers/bus/vdev/vdev.c
> @@ -577,6 +577,9 @@ vdev_cleanup(void)
> const struct rte_vdev_driver *drv;
> int ret = 0;
>
> + if (dev->device.driver == NULL)
> + continue;
> +
> drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver);
>
> if (drv == NULL || drv->remove == NULL)
If dev->device.driver != NULL, then drv won't be NULL.
--
David Marchand
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] bus/vdev: vdev_cleanup checks dev->device.driver
2022-10-19 11:39 ` David Marchand
@ 2022-10-19 13:27 ` Zhangfei Gao
2022-10-19 13:37 ` Zhangfei Gao
1 sibling, 0 replies; 7+ messages in thread
From: Zhangfei Gao @ 2022-10-19 13:27 UTC (permalink / raw)
To: David Marchand; +Cc: Anatoly Burakov, Akhil Goyal, Fan Zhang, dev, acc
Hi, David
On Wed, 19 Oct 2022 at 19:39, David Marchand <david.marchand@redhat.com> wrote:
>
> On Wed, Oct 19, 2022 at 12:55 PM Zhangfei Gao <zhangfei.gao@linaro.org> wrote:
> >
> > The vdev_probe calls driver->probe, which may fail
> > and dev->device.driver will still be NULL.
> >
> > In vdev_cleanup, drv = container_of(dev->device.driver) returns !NULL,
> > then drv->remove will trigger Segmentation fault.
> > Fix it by checking dev->device.driver first.
> >
> > Log:
> > Thread 1 "dpdk-test" received signal SIGSEGV, Segmentation fault.
> > 0x00000000012c484d in vdev_cleanup ()
>
> I suspect you hit this issue when running some crypto autotest.
> Can you confirm?
Yes, I am testing uadk crypto autotest on x86,
Since there is no hardware, so probe fail and return (which is expected)
But quit dpdk-test triggered Segmentation fault
$ sudo dpdk-test --vdev=crypto_uadk --log-level=6
vdev_probe(): failed to initialize crypto_uadk device
EAL: Bus (vdev) probe failed.
TELEMETRY: No legacy callbacks, legacy socket not created
RTE>>quit
Segmentation fault
>
>
> The commit that introduced the issue should be mentionned, with a
> Fixes: tag, like:
> Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
OK, will update
Thanks David.
>
> >
> > Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
> > ---
> > drivers/bus/vdev/vdev.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
> > index f5b43f1930..fbdaf68380 100644
> > --- a/drivers/bus/vdev/vdev.c
> > +++ b/drivers/bus/vdev/vdev.c
> > @@ -577,6 +577,9 @@ vdev_cleanup(void)
> > const struct rte_vdev_driver *drv;
> > int ret = 0;
> >
> > + if (dev->device.driver == NULL)
> > + continue;
> > +
> > drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver);
> >
> > if (drv == NULL || drv->remove == NULL)
>
> If dev->device.driver != NULL, then drv won't be NULL.
>
>
> --
> David Marchand
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] bus/vdev: vdev_cleanup checks dev->device.driver
2022-10-19 11:39 ` David Marchand
2022-10-19 13:27 ` Zhangfei Gao
@ 2022-10-19 13:37 ` Zhangfei Gao
1 sibling, 0 replies; 7+ messages in thread
From: Zhangfei Gao @ 2022-10-19 13:37 UTC (permalink / raw)
To: David Marchand; +Cc: Anatoly Burakov, Akhil Goyal, Fan Zhang, dev, acc
On Wed, 19 Oct 2022 at 19:39, David Marchand <david.marchand@redhat.com> wrote:
>
> On Wed, Oct 19, 2022 at 12:55 PM Zhangfei Gao <zhangfei.gao@linaro.org> wrote:
> >
> > The vdev_probe calls driver->probe, which may fail
> > and dev->device.driver will still be NULL.
> >
> > In vdev_cleanup, drv = container_of(dev->device.driver) returns !NULL,
> > then drv->remove will trigger Segmentation fault.
> > Fix it by checking dev->device.driver first.
> >
> > Log:
> > Thread 1 "dpdk-test" received signal SIGSEGV, Segmentation fault.
> > 0x00000000012c484d in vdev_cleanup ()
>
> I suspect you hit this issue when running some crypto autotest.
> Can you confirm?
>
>
> The commit that introduced the issue should be mentionned, with a
> Fixes: tag, like:
> Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
>
> >
> > Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
> > ---
> > drivers/bus/vdev/vdev.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
> > index f5b43f1930..fbdaf68380 100644
> > --- a/drivers/bus/vdev/vdev.c
> > +++ b/drivers/bus/vdev/vdev.c
> > @@ -577,6 +577,9 @@ vdev_cleanup(void)
> > const struct rte_vdev_driver *drv;
> > int ret = 0;
> >
> > + if (dev->device.driver == NULL)
> > + continue;
> > +
> > drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver);
> >
> > if (drv == NULL || drv->remove == NULL)
>
> If dev->device.driver != NULL, then drv won't be NULL.
Sorry, I miss this, add log to be clear
$ sudo dpdk-test --vdev=crypto_uadk --log-level=6
vdev_probe_all_drivers dev->device.driver=(nil) ret=-19
vdev_probe(): failed to initialize crypto_uadk device
EAL: Bus (vdev) probe failed.
TELEMETRY: No legacy callbacks, legacy socket not created
RTE>>quit
vdev_cleanup dev->device.driver=(nil)
vdev_cleanup drv=0xfffffffffffffff0
Segmentation fault
>
>
> --
> David Marchand
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] bus/vdev: vdev_cleanup checks dev->device.driver
2022-10-19 10:48 [PATCH] bus/vdev: vdev_cleanup checks dev->device.driver Zhangfei Gao
2022-10-19 11:39 ` David Marchand
@ 2022-10-19 13:56 ` Zhangfei Gao
2022-10-19 14:08 ` [PATCH v2 resend] " Zhangfei Gao
2 siblings, 0 replies; 7+ messages in thread
From: Zhangfei Gao @ 2022-10-19 13:56 UTC (permalink / raw)
To: Anatoly Burakov, Akhil Goyal, Fan Zhang, David Marchand
Cc: dev, acc, Zhangfei Gao
vdev_probe calls driver->probe and set dev->device.driver,
which will be NULL if probe fails.
In vdev_cleanup, drv = container_of(dev->device.driver)
drv will be !NULL in this case. anc cause drv->remove
Segmentation fault.
Fixed by checking dev->device.driver before.
Log:
$ sudo dpdk-test --vdev=crypto_uadk --log-level=6
vdev_probe(): failed to initialize crypto_uadk device
EAL: Bus (vdev) probe failed.
RTE>>quit
Segmentation fault
Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
v2:
Suggested by David Marchand <david.marchand@redhat.com>
1. Add Fixes
2. "If dev->device.driver != NULL, then drv won't be NULL", so remove it
drivers/bus/vdev/vdev.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index f5b43f1930..41bc07dde7 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -577,9 +577,12 @@ vdev_cleanup(void)
const struct rte_vdev_driver *drv;
int ret = 0;
+ if (dev->device.driver == NULL)
+ continue;
+
drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver);
- if (drv == NULL || drv->remove == NULL)
+ if (drv->remove == NULL)
continue;
ret = drv->remove(dev);
--
2.38.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 resend] bus/vdev: vdev_cleanup checks dev->device.driver
2022-10-19 10:48 [PATCH] bus/vdev: vdev_cleanup checks dev->device.driver Zhangfei Gao
2022-10-19 11:39 ` David Marchand
2022-10-19 13:56 ` [PATCH v2] " Zhangfei Gao
@ 2022-10-19 14:08 ` Zhangfei Gao
2022-10-20 11:32 ` David Marchand
2 siblings, 1 reply; 7+ messages in thread
From: Zhangfei Gao @ 2022-10-19 14:08 UTC (permalink / raw)
To: Anatoly Burakov, Akhil Goyal, Fan Zhang, David Marchand
Cc: dev, acc, Zhangfei Gao
vdev_probe calls driver->probe and set dev->device.driver,
which will be NULL if the probe fails.
In vdev_cleanup, drv = container_of(dev->device.driver)
drv will be !NULL in this case, causing drv->remove
Segmentation fault.
Fixed by checking dev->device.driver before.
Log:
$ sudo dpdk-test --vdev=crypto_uadk --log-level=6
vdev_probe(): failed to initialize crypto_uadk device
EAL: Bus (vdev) probe failed.
RTE>>quit
Segmentation fault
Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
v2:
Suggested by David Marchand <david.marchand@redhat.com>
1. Add Fixes
2. "If dev->device.driver != NULL, then drv won't be NULL", so remove it
drivers/bus/vdev/vdev.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index f5b43f1930..41bc07dde7 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -577,9 +577,12 @@ vdev_cleanup(void)
const struct rte_vdev_driver *drv;
int ret = 0;
+ if (dev->device.driver == NULL)
+ continue;
+
drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver);
- if (drv == NULL || drv->remove == NULL)
+ if (drv->remove == NULL)
continue;
ret = drv->remove(dev);
--
2.38.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 resend] bus/vdev: vdev_cleanup checks dev->device.driver
2022-10-19 14:08 ` [PATCH v2 resend] " Zhangfei Gao
@ 2022-10-20 11:32 ` David Marchand
0 siblings, 0 replies; 7+ messages in thread
From: David Marchand @ 2022-10-20 11:32 UTC (permalink / raw)
To: Zhangfei Gao; +Cc: Anatoly Burakov, Akhil Goyal, Fan Zhang, dev, acc
On Wed, Oct 19, 2022 at 4:14 PM Zhangfei Gao <zhangfei.gao@linaro.org> wrote:
>
> vdev_probe calls driver->probe and set dev->device.driver,
> which will be NULL if the probe fails.
>
> In vdev_cleanup, drv = container_of(dev->device.driver)
> drv will be !NULL in this case, causing drv->remove
> Segmentation fault.
>
> Fixed by checking dev->device.driver before.
>
> Log:
> $ sudo dpdk-test --vdev=crypto_uadk --log-level=6
> vdev_probe(): failed to initialize crypto_uadk device
> EAL: Bus (vdev) probe failed.
> RTE>>quit
> Segmentation fault
>
> Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Applied, thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-10-20 11:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 10:48 [PATCH] bus/vdev: vdev_cleanup checks dev->device.driver Zhangfei Gao
2022-10-19 11:39 ` David Marchand
2022-10-19 13:27 ` Zhangfei Gao
2022-10-19 13:37 ` Zhangfei Gao
2022-10-19 13:56 ` [PATCH v2] " Zhangfei Gao
2022-10-19 14:08 ` [PATCH v2 resend] " Zhangfei Gao
2022-10-20 11:32 ` David Marchand
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).