From: Szilveszter Ördög Date: Fri, 6 Aug 2010 01:26:38 +0000 (+0800) Subject: crypto: hash - Fix handling of small unaligned buffers X-Git-Tag: v2.6.36-rc4~83^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=23a75eee070f1370bee803a34f285cf81eb5f331;p=profile%2Fivi%2Fkernel-x86-ivi.git crypto: hash - Fix handling of small unaligned buffers If a scatterwalk chain contains an entry with an unaligned offset then hash_walk_next() will cut off the next step at the next alignment point. However, if the entry ends before the next alignment point then we a loop, which leads to a kernel oops. Fix this by checking whether the next aligment point is before the end of the current entry. Signed-off-by: Szilveszter Ördög Acked-by: David S. Miller Signed-off-by: Herbert Xu --- diff --git a/crypto/ahash.c b/crypto/ahash.c index b8c59b8..f669822 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -47,8 +47,11 @@ static int hash_walk_next(struct crypto_hash_walk *walk) walk->data = crypto_kmap(walk->pg, 0); walk->data += offset; - if (offset & alignmask) - nbytes = alignmask + 1 - (offset & alignmask); + if (offset & alignmask) { + unsigned int unaligned = alignmask + 1 - (offset & alignmask); + if (nbytes > unaligned) + nbytes = unaligned; + } walk->entrylen -= nbytes; return nbytes;