summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2016-05-04 17:52:56 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-05-18 17:03:58 -0700
commitcc440a5b68873b7b98c3130d09a69a1b13acb0b7 (patch)
treeb2925e5ba182a52322ef2db9966eb1974a0af47d
parent1c767107ef341cdc080d44d3ee1c9ca1b6957ce0 (diff)
downloadlwn-cc440a5b68873b7b98c3130d09a69a1b13acb0b7.tar.gz
lwn-cc440a5b68873b7b98c3130d09a69a1b13acb0b7.zip
crypto: hash - Fix page length clamping in hash walk
commit 13f4bb78cf6a312bbdec367ba3da044b09bf0e29 upstream. The crypto hash walk code is broken when supplied with an offset greater than or equal to PAGE_SIZE. This patch fixes it by adjusting walk->pg and walk->offset when this happens. Reported-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--crypto/ahash.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c
index 865ef923eda6..7cddee979ddd 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -64,8 +64,9 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk)
struct scatterlist *sg;
sg = walk->sg;
- walk->pg = sg_page(sg);
walk->offset = sg->offset;
+ walk->pg = sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT);
+ walk->offset = offset_in_page(walk->offset);
walk->entrylen = sg->length;
if (walk->entrylen > walk->total)