summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-03-26 08:53:25 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2018-03-31 01:34:19 +0800
commita0f776c79d9472f33a8c05f7a429c209e6d839ad (patch)
treef30639ba56f99c2d5f4d4fa01ce95ba84bb53b39
parent4937da0d9d498690ebdbd007ebde453a1733591f (diff)
downloadlinux-crypto-a0f776c79d9472f33a8c05f7a429c209e6d839ad.tar.gz
linux-crypto-a0f776c79d9472f33a8c05f7a429c209e6d839ad.zip
crypto: ahash - Fix early termination in hash walk
When we have an unaligned SG list entry where there is no leftover aligned data, the hash walk code will incorrectly return zero as if the entire SG list has been processed. This patch fixes it by moving onto the next page instead. Reported-by: Eli Cooper <elicooper@gmx.com> Cc: <stable@vger.kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/ahash.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c
index f732dd9d..a64c1431 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -92,13 +92,14 @@ int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err)
if (nbytes && walk->offset & alignmask && !err) {
walk->offset = ALIGN(walk->offset, alignmask + 1);
- walk->data += walk->offset;
-
nbytes = min(nbytes,
((unsigned int)(PAGE_SIZE)) - walk->offset);
walk->entrylen -= nbytes;
- return nbytes;
+ if (nbytes) {
+ walk->data += walk->offset;
+ return nbytes;
+ }
}
if (walk->flags & CRYPTO_ALG_ASYNC)