Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1603377 > unrolled thread
| Started by | Krzysztof Kozlowski <krzk@kernel.org> |
|---|---|
| First post | 2017-03-17 16:00 +0100 |
| Last post | 2017-03-24 15:20 +0100 |
| Articles | 6 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/4] crypto: s5p-sss - Fix and minor improvements Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-17 16:00 +0100
[PATCH 2/4] crypto: s5p-sss - Remove unused variant field from state container Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-17 16:20 +0100
Re: [PATCH 2/4] crypto: s5p-sss - Remove unused variant field from state container Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> - 2017-03-17 19:00 +0100
[PATCH 1/4] crypto: s5p-sss - Close possible race for completed requests Krzysztof Kozlowski <krzk@kernel.org> - 2017-03-17 16:20 +0100
Re: [PATCH 1/4] crypto: s5p-sss - Close possible race for completed requests Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> - 2017-03-17 19:00 +0100
Re: [PATCH 0/4] crypto: s5p-sss - Fix and minor improvements Herbert Xu <herbert@gondor.apana.org.au> - 2017-03-24 15:20 +0100
| From | Krzysztof Kozlowski <krzk@kernel.org> |
|---|---|
| Date | 2017-03-17 16:00 +0100 |
| Subject | [PATCH 0/4] crypto: s5p-sss - Fix and minor improvements |
| Message-ID | <tm1we-80O-19@gated-at.bofh.it> |
Hi, I still did not fix the NULL pointer dereference reported by Nathan Royce [1], but I got some other improvements. Testing done on Odroid U3 (Exynos4412) with tcrypt and cryptsetup. Best regards, Krzysztof [1] https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1351149.html Krzysztof Kozlowski (4): crypto: s5p-sss - Close possible race for completed requests crypto: s5p-sss - Remove unused variant field from state container crypto: s5p-sss - Document the struct s5p_aes_dev crypto: s5p-sss - Use mutex instead of spinlock drivers/crypto/s5p-sss.c | 70 +++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 25 deletions(-) -- 2.9.3
[toc] | [next] | [standalone]
| From | Krzysztof Kozlowski <krzk@kernel.org> |
|---|---|
| Date | 2017-03-17 16:20 +0100 |
| Subject | [PATCH 2/4] crypto: s5p-sss - Remove unused variant field from state container |
| Message-ID | <tm1PA-8o8-3@gated-at.bofh.it> |
| In reply to | #1603377 |
The driver uses type of device (variant) only during probe so there is
no need to store it for later.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/crypto/s5p-sss.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index 6c620487e9c2..35ea84b7d775 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -190,8 +190,6 @@ struct s5p_aes_dev {
struct crypto_queue queue;
bool busy;
spinlock_t lock;
-
- struct samsung_aes_variant *variant;
};
static struct s5p_aes_dev *s5p_dev;
@@ -852,7 +850,6 @@ static int s5p_aes_probe(struct platform_device *pdev)
}
pdata->busy = false;
- pdata->variant = variant;
pdata->dev = dev;
platform_set_drvdata(pdev, pdata);
s5p_dev = pdata;
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> |
|---|---|
| Date | 2017-03-17 19:00 +0100 |
| Subject | Re: [PATCH 2/4] crypto: s5p-sss - Remove unused variant field from state container |
| Message-ID | <tm4kq-1GF-21@gated-at.bofh.it> |
| In reply to | #1603392 |
On Friday, March 17, 2017 04:49:20 PM Krzysztof Kozlowski wrote: > The driver uses type of device (variant) only during probe so there is > no need to store it for later. > > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics
[toc] | [prev] | [next] | [standalone]
| From | Krzysztof Kozlowski <krzk@kernel.org> |
|---|---|
| Date | 2017-03-17 16:20 +0100 |
| Subject | [PATCH 1/4] crypto: s5p-sss - Close possible race for completed requests |
| Message-ID | <tm1PA-8o8-9@gated-at.bofh.it> |
| In reply to | #1603377 |
Driver is capable of handling only one request at a time and it stores
it in its state container struct s5p_aes_dev. This stored request must be
protected between concurrent invocations (e.g. completing current
request and scheduling new one). Combination of lock and "busy" field
is used for that purpose.
When "busy" field is true, the driver will not accept new request thus
it will not overwrite currently handled data.
However commit 28b62b145868 ("crypto: s5p-sss - Fix spinlock recursion
on LRW(AES)") moved some of the write to "busy" field out of a lock
protected critical section. This might lead to potential race between
completing current request and scheduling a new one. Effectively the
request completion might try to operate on new crypto request.
Cc: <stable@vger.kernel.org> # v4.10.x
Fixes: 28b62b145868 ("crypto: s5p-sss - Fix spinlock recursion on LRW(AES)")
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/crypto/s5p-sss.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index 1b9da3dc799b..6c620487e9c2 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -287,7 +287,6 @@ static void s5p_sg_done(struct s5p_aes_dev *dev)
static void s5p_aes_complete(struct s5p_aes_dev *dev, int err)
{
dev->req->base.complete(&dev->req->base, err);
- dev->busy = false;
}
static void s5p_unset_outdata(struct s5p_aes_dev *dev)
@@ -462,7 +461,7 @@ static irqreturn_t s5p_aes_interrupt(int irq, void *dev_id)
spin_unlock_irqrestore(&dev->lock, flags);
s5p_aes_complete(dev, 0);
- dev->busy = true;
+ /* Device is still busy */
tasklet_schedule(&dev->tasklet);
} else {
/*
@@ -483,6 +482,7 @@ static irqreturn_t s5p_aes_interrupt(int irq, void *dev_id)
error:
s5p_sg_done(dev);
+ dev->busy = false;
spin_unlock_irqrestore(&dev->lock, flags);
s5p_aes_complete(dev, err);
@@ -634,6 +634,7 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode)
indata_error:
s5p_sg_done(dev);
+ dev->busy = false;
spin_unlock_irqrestore(&dev->lock, flags);
s5p_aes_complete(dev, err);
}
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> |
|---|---|
| Date | 2017-03-17 19:00 +0100 |
| Subject | Re: [PATCH 1/4] crypto: s5p-sss - Close possible race for completed requests |
| Message-ID | <tm4kq-1GF-25@gated-at.bofh.it> |
| In reply to | #1603395 |
On Friday, March 17, 2017 04:49:19 PM Krzysztof Kozlowski wrote:
> Driver is capable of handling only one request at a time and it stores
> it in its state container struct s5p_aes_dev. This stored request must be
> protected between concurrent invocations (e.g. completing current
> request and scheduling new one). Combination of lock and "busy" field
> is used for that purpose.
>
> When "busy" field is true, the driver will not accept new request thus
> it will not overwrite currently handled data.
>
> However commit 28b62b145868 ("crypto: s5p-sss - Fix spinlock recursion
> on LRW(AES)") moved some of the write to "busy" field out of a lock
> protected critical section. This might lead to potential race between
> completing current request and scheduling a new one. Effectively the
> request completion might try to operate on new crypto request.
>
> Cc: <stable@vger.kernel.org> # v4.10.x
> Fixes: 28b62b145868 ("crypto: s5p-sss - Fix spinlock recursion on LRW(AES)")
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
[toc] | [prev] | [next] | [standalone]
| From | Herbert Xu <herbert@gondor.apana.org.au> |
|---|---|
| Date | 2017-03-24 15:20 +0100 |
| Message-ID | <toyen-2LK-45@gated-at.bofh.it> |
| In reply to | #1603377 |
On Fri, Mar 17, 2017 at 04:49:18PM +0200, Krzysztof Kozlowski wrote: > Hi, > > I still did not fix the NULL pointer dereference reported by > Nathan Royce [1], but I got some other improvements. > > Testing done on Odroid U3 (Exynos4412) with tcrypt and cryptsetup. > > Best regards, > Krzysztof Patches 1-3 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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web