diff options
author | Szilveszter Ördög <slipszi@gmail.com> | 2010-08-06 09:26:38 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2010-08-06 09:26:38 +0800 |
commit | aa4cfece0b65a414b0c3f4543e5f6572bad9397a (patch) | |
tree | 4bbca69d17d7e664d6d8b98d7790d81c70cf3ef3 | |
parent | cbd4a4e4cc49ee53f6f0b07464443ed61315dfb2 (diff) | |
download | linux-crypto-aa4cfece0b65a414b0c3f4543e5f6572bad9397a.tar.gz linux-crypto-aa4cfece0b65a414b0c3f4543e5f6572bad9397a.zip |
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 <slipszi@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | crypto/ahash.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c index b8c59b88..f669822a 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; |