* [PATCH] drivers: crypto: picoxcell_crypto: Fix potential race condition bug
@ 2020-08-11 12:30 madhuparnabhowmik10
2020-08-13 11:33 ` Jamie Iles
2020-08-21 7:58 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: madhuparnabhowmik10 @ 2020-08-11 12:30 UTC (permalink / raw)
To: jamie, herbert, davem
Cc: linux-arm-kernel, linux-crypto, linux-kernel, andrianov,
ldv-project, Madhuparna Bhowmik
From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
engine->stat_irq_thresh was initialized after device_create_file() in
the probe function, the initialization may race with call to
spacc_stat_irq_thresh_store() which updates engine->stat_irq_thresh,
therefore initialize it before creating the file in probe function.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
---
drivers/crypto/picoxcell_crypto.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c
index dac6eb37fff9..fb34bf92861d 100644
--- a/drivers/crypto/picoxcell_crypto.c
+++ b/drivers/crypto/picoxcell_crypto.c
@@ -1685,11 +1685,6 @@ static int spacc_probe(struct platform_device *pdev)
goto err_clk_put;
}
- ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh);
- if (ret)
- goto err_clk_disable;
-
-
/*
* Use an IRQ threshold of 50% as a default. This seems to be a
* reasonable trade off of latency against throughput but can be
@@ -1697,6 +1692,10 @@ static int spacc_probe(struct platform_device *pdev)
*/
engine->stat_irq_thresh = (engine->fifo_sz / 2);
+ ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh);
+ if (ret)
+ goto err_clk_disable;
+
/*
* Configure the interrupts. We only use the STAT_CNT interrupt as we
* only submit a new packet for processing when we complete another in
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: crypto: picoxcell_crypto: Fix potential race condition bug
2020-08-11 12:30 [PATCH] drivers: crypto: picoxcell_crypto: Fix potential race condition bug madhuparnabhowmik10
@ 2020-08-13 11:33 ` Jamie Iles
2020-08-21 7:58 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Jamie Iles @ 2020-08-13 11:33 UTC (permalink / raw)
To: madhuparnabhowmik10
Cc: jamie, herbert, davem, linux-arm-kernel, linux-crypto,
linux-kernel, andrianov, ldv-project
On Tue, Aug 11, 2020 at 06:00:24PM +0530, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
>
> engine->stat_irq_thresh was initialized after device_create_file() in
> the probe function, the initialization may race with call to
> spacc_stat_irq_thresh_store() which updates engine->stat_irq_thresh,
> therefore initialize it before creating the file in probe function.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Acked-by: Jamie Iles <jamie@jamieiles.com>
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: crypto: picoxcell_crypto: Fix potential race condition bug
2020-08-11 12:30 [PATCH] drivers: crypto: picoxcell_crypto: Fix potential race condition bug madhuparnabhowmik10
2020-08-13 11:33 ` Jamie Iles
@ 2020-08-21 7:58 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2020-08-21 7:58 UTC (permalink / raw)
To: madhuparnabhowmik10
Cc: jamie, davem, linux-arm-kernel, linux-crypto, linux-kernel,
andrianov, ldv-project
On Tue, Aug 11, 2020 at 06:00:24PM +0530, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
>
> engine->stat_irq_thresh was initialized after device_create_file() in
> the probe function, the initialization may race with call to
> spacc_stat_irq_thresh_store() which updates engine->stat_irq_thresh,
> therefore initialize it before creating the file in probe function.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> ---
> drivers/crypto/picoxcell_crypto.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-21 7:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11 12:30 [PATCH] drivers: crypto: picoxcell_crypto: Fix potential race condition bug madhuparnabhowmik10
2020-08-13 11:33 ` Jamie Iles
2020-08-21 7:58 ` Herbert Xu
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).