From: Krzysztof Kozlowski <krzk@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
Vladimir Zapolskiy <vz@mleia.com>
Cc: Nathan Royce <nroycea+kernel@gmail.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
"# v4 . 10 . x" <stable@vger.kernel.org>
Subject: [PATCH 1/4] crypto: s5p-sss - Close possible race for completed requests
Date: Fri, 17 Mar 2017 16:49:19 +0200 [thread overview]
Message-ID: <20170317144922.27379-2-krzk@kernel.org> (raw)
In-Reply-To: <20170317144922.27379-1-krzk@kernel.org>
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
next prev parent reply other threads:[~2017-03-17 14:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 14:49 [PATCH 0/4] crypto: s5p-sss - Fix and minor improvements Krzysztof Kozlowski
2017-03-17 14:49 ` Krzysztof Kozlowski [this message]
[not found] ` <CGME20170317175731epcas5p4c078b2e8bfa782fc2bd2a0412f51f03f@epcas5p4.samsung.com>
2017-03-17 17:57 ` [PATCH 1/4] crypto: s5p-sss - Close possible race for completed requests Bartlomiej Zolnierkiewicz
2017-03-17 14:49 ` [PATCH 2/4] crypto: s5p-sss - Remove unused variant field from state container Krzysztof Kozlowski
[not found] ` <CGME20170317175742epcas1p4de223069256de479fb9cd3b56375bd4d@epcas1p4.samsung.com>
2017-03-17 17:57 ` Bartlomiej Zolnierkiewicz
2017-03-17 14:49 ` [PATCH 3/4] crypto: s5p-sss - Document the struct s5p_aes_dev Krzysztof Kozlowski
[not found] ` <CGME20170317175754epcas5p473bcb23492a1cd249f973494b719ece3@epcas5p4.samsung.com>
2017-03-17 17:57 ` Bartlomiej Zolnierkiewicz
2017-03-17 14:49 ` [PATCH 4/4] crypto: s5p-sss - Use mutex instead of spinlock Krzysztof Kozlowski
[not found] ` <CGME20170317172831epcas1p12280386c43fd0b819bb87cf4ba78eab3@epcas1p1.samsung.com>
2017-03-17 17:28 ` Bartlomiej Zolnierkiewicz
2017-03-17 17:54 ` Krzysztof Kozlowski
2017-03-24 14:13 ` [PATCH 0/4] crypto: s5p-sss - Fix and minor improvements Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170317144922.27379-2-krzk@kernel.org \
--to=krzk@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nroycea+kernel@gmail.com \
--cc=stable@vger.kernel.org \
--cc=vz@mleia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).