* [PATCH] usb/c67x00/c67x00-drv: Fix Data Race bug
@ 2020-08-26 14:44 madhuparnabhowmik10
2020-08-28 7:40 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: madhuparnabhowmik10 @ 2020-08-26 14:44 UTC (permalink / raw)
To: jacmet, gregkh
Cc: linux-usb, linux-kernel, ldv-project, andrianov, Madhuparna Bhowmik
From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Currently in c67x00_drv_probe() IRQ is requested before calling
c67x00_probe_sie() and hence if interrupt happens the reading of certain
variables in the handler can race with initialization of the variables,
for e.g. sie->sie_num is written in c67x00_probe_sie() and read in
c67x00_hcd_irq().
Hence, this patch calls c67x00_probe_sie() before requesting IRQ in
probe.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
---
drivers/usb/c67x00/c67x00-drv.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/c67x00/c67x00-drv.c b/drivers/usb/c67x00/c67x00-drv.c
index 53838e7d4eef..2e816d5ca0eb 100644
--- a/drivers/usb/c67x00/c67x00-drv.c
+++ b/drivers/usb/c67x00/c67x00-drv.c
@@ -146,6 +146,9 @@ static int c67x00_drv_probe(struct platform_device *pdev)
c67x00_ll_init(c67x00);
c67x00_ll_hpi_reg_init(c67x00);
+ for (i = 0; i < C67X00_SIES; i++)
+ c67x00_probe_sie(&c67x00->sie[i], c67x00, i);
+
ret = request_irq(res2->start, c67x00_irq, 0, pdev->name, c67x00);
if (ret) {
dev_err(&pdev->dev, "Cannot claim IRQ\n");
@@ -158,9 +161,6 @@ static int c67x00_drv_probe(struct platform_device *pdev)
goto reset_failed;
}
- for (i = 0; i < C67X00_SIES; i++)
- c67x00_probe_sie(&c67x00->sie[i], c67x00, i);
-
platform_set_drvdata(pdev, c67x00);
return 0;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb/c67x00/c67x00-drv: Fix Data Race bug
2020-08-26 14:44 [PATCH] usb/c67x00/c67x00-drv: Fix Data Race bug madhuparnabhowmik10
@ 2020-08-28 7:40 ` Greg KH
2020-08-28 16:19 ` Madhuparna Bhowmik
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2020-08-28 7:40 UTC (permalink / raw)
To: madhuparnabhowmik10
Cc: jacmet, linux-usb, linux-kernel, ldv-project, andrianov
On Wed, Aug 26, 2020 at 08:14:59PM +0530, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
>
> Currently in c67x00_drv_probe() IRQ is requested before calling
> c67x00_probe_sie() and hence if interrupt happens the reading of certain
> variables in the handler can race with initialization of the variables,
> for e.g. sie->sie_num is written in c67x00_probe_sie() and read in
> c67x00_hcd_irq().
> Hence, this patch calls c67x00_probe_sie() before requesting IRQ in
> probe.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> ---
> drivers/usb/c67x00/c67x00-drv.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/c67x00/c67x00-drv.c b/drivers/usb/c67x00/c67x00-drv.c
> index 53838e7d4eef..2e816d5ca0eb 100644
> --- a/drivers/usb/c67x00/c67x00-drv.c
> +++ b/drivers/usb/c67x00/c67x00-drv.c
> @@ -146,6 +146,9 @@ static int c67x00_drv_probe(struct platform_device *pdev)
> c67x00_ll_init(c67x00);
> c67x00_ll_hpi_reg_init(c67x00);
>
> + for (i = 0; i < C67X00_SIES; i++)
> + c67x00_probe_sie(&c67x00->sie[i], c67x00, i);
> +
> ret = request_irq(res2->start, c67x00_irq, 0, pdev->name, c67x00);
> if (ret) {
> dev_err(&pdev->dev, "Cannot claim IRQ\n");
> @@ -158,9 +161,6 @@ static int c67x00_drv_probe(struct platform_device *pdev)
> goto reset_failed;
> }
>
> - for (i = 0; i < C67X00_SIES; i++)
> - c67x00_probe_sie(&c67x00->sie[i], c67x00, i);
> -
> platform_set_drvdata(pdev, c67x00);
>
> return 0;
Have you tested this on hardware to verify it works properly?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb/c67x00/c67x00-drv: Fix Data Race bug
2020-08-28 7:40 ` Greg KH
@ 2020-08-28 16:19 ` Madhuparna Bhowmik
0 siblings, 0 replies; 3+ messages in thread
From: Madhuparna Bhowmik @ 2020-08-28 16:19 UTC (permalink / raw)
To: Greg KH
Cc: jacmet, linux-usb, Linux Kernel Mailing List, ldv-project, andrianov
On Fri, Aug 28, 2020 at 1:10 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Aug 26, 2020 at 08:14:59PM +0530, madhuparnabhowmik10@gmail.com wrote:
> > From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> >
> > Currently in c67x00_drv_probe() IRQ is requested before calling
> > c67x00_probe_sie() and hence if interrupt happens the reading of certain
> > variables in the handler can race with initialization of the variables,
> > for e.g. sie->sie_num is written in c67x00_probe_sie() and read in
> > c67x00_hcd_irq().
> > Hence, this patch calls c67x00_probe_sie() before requesting IRQ in
> > probe.
> >
> > Found by Linux Driver Verification project (linuxtesting.org).
> >
> > Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > ---
> > drivers/usb/c67x00/c67x00-drv.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/usb/c67x00/c67x00-drv.c b/drivers/usb/c67x00/c67x00-drv.c
> > index 53838e7d4eef..2e816d5ca0eb 100644
> > --- a/drivers/usb/c67x00/c67x00-drv.c
> > +++ b/drivers/usb/c67x00/c67x00-drv.c
> > @@ -146,6 +146,9 @@ static int c67x00_drv_probe(struct platform_device *pdev)
> > c67x00_ll_init(c67x00);
> > c67x00_ll_hpi_reg_init(c67x00);
> >
> > + for (i = 0; i < C67X00_SIES; i++)
> > + c67x00_probe_sie(&c67x00->sie[i], c67x00, i);
> > +
> > ret = request_irq(res2->start, c67x00_irq, 0, pdev->name, c67x00);
> > if (ret) {
> > dev_err(&pdev->dev, "Cannot claim IRQ\n");
> > @@ -158,9 +161,6 @@ static int c67x00_drv_probe(struct platform_device *pdev)
> > goto reset_failed;
> > }
> >
> > - for (i = 0; i < C67X00_SIES; i++)
> > - c67x00_probe_sie(&c67x00->sie[i], c67x00, i);
> > -
> > platform_set_drvdata(pdev, c67x00);
> >
> > return 0;
>
> Have you tested this on hardware to verify it works properly?
No, I haven't, don't think I have the relevant hardware.
It would be great if someone could test this and add a Tested-by tag.
Thanks,
Madhuparna
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-28 16:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 14:44 [PATCH] usb/c67x00/c67x00-drv: Fix Data Race bug madhuparnabhowmik10
2020-08-28 7:40 ` Greg KH
2020-08-28 16:19 ` Madhuparna Bhowmik
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).