From: Corentin Labbe <clabbe@baylibre.com>
To: arnd@arndb.de, davem@davemloft.net, herbert@gondor.apana.org.au,
jernej.skrabec@siol.net, mripard@kernel.org, wens@csie.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
linux-sunxi@googlegroups.com,
Corentin Labbe <clabbe@baylibre.com>,
linux-arm-kernel@lists.infradead.org,
linux-crypto@vger.kernel.org
Subject: [PATCH v4 2/8] crypto: sun4i-ss: checking sg length is not sufficient
Date: Mon, 14 Dec 2020 20:02:26 +0000 [thread overview]
Message-ID: <20201214200232.17357-3-clabbe@baylibre.com> (raw)
In-Reply-To: <20201214200232.17357-1-clabbe@baylibre.com>
The optimized cipher function need length multiple of 4 bytes.
But it get sometimes odd length.
This is due to SG data could be stored with an offset.
So the fix is to check also if the offset is aligned with 4 bytes.
Fixes: 6298e948215f2 ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator")
Cc: <stable@vger.kernel.org>
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c
index 19f1aa577ed4..f49797588329 100644
--- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c
+++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c
@@ -186,12 +186,12 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
* we can use the SS optimized function
*/
while (in_sg && no_chunk == 1) {
- if (in_sg->length % 4)
+ if ((in_sg->length | in_sg->offset) & 3u)
no_chunk = 0;
in_sg = sg_next(in_sg);
}
while (out_sg && no_chunk == 1) {
- if (out_sg->length % 4)
+ if ((out_sg->length | out_sg->offset) & 3u)
no_chunk = 0;
out_sg = sg_next(out_sg);
}
--
2.26.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-12-14 20:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-14 20:02 [PATCH v4 0/8] crypto: sun4i-ss: prevent always fallback for ciphers Corentin Labbe
2020-12-14 20:02 ` [PATCH v4 1/8] crypto: sun4i-ss: linearize buffers content must be kept Corentin Labbe
2020-12-14 20:02 ` Corentin Labbe [this message]
2020-12-14 20:02 ` [PATCH v4 3/8] crypto: sun4i-ss: IV register does not work on A10 and A13 Corentin Labbe
2020-12-14 20:02 ` [PATCH v4 4/8] crypto: sun4i-ss: handle BigEndian for cipher Corentin Labbe
2020-12-14 20:02 ` [PATCH v4 5/8] crypto: sun4i-ss: initialize need_fallback Corentin Labbe
2020-12-14 20:02 ` [PATCH v4 6/8] crypto: sun4i-ss: fix kmap usage Corentin Labbe
2020-12-14 20:02 ` [PATCH v4 7/8] crypto: sun4i-ss: enabled stats via debugfs Corentin Labbe
2020-12-14 20:02 ` [PATCH v4 8/8] crypto: sun4i-ss: add SPDX header and remove blank lines Corentin Labbe
2021-01-02 22:07 ` [PATCH v4 0/8] crypto: sun4i-ss: prevent always fallback for ciphers 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=20201214200232.17357-3-clabbe@baylibre.com \
--to=clabbe@baylibre.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=jernej.skrabec@siol.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=mripard@kernel.org \
--cc=stable@vger.kernel.org \
--cc=wens@csie.org \
/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).