提交 23a75eee 编写于 作者: S Szilveszter Ördög 提交者: Herbert Xu

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: NSzilveszter Ördög <slipszi@gmail.com>
Acked-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 fc1caf6e
...@@ -47,8 +47,11 @@ static int hash_walk_next(struct crypto_hash_walk *walk) ...@@ -47,8 +47,11 @@ static int hash_walk_next(struct crypto_hash_walk *walk)
walk->data = crypto_kmap(walk->pg, 0); walk->data = crypto_kmap(walk->pg, 0);
walk->data += offset; walk->data += offset;
if (offset & alignmask) if (offset & alignmask) {
nbytes = alignmask + 1 - (offset & alignmask); unsigned int unaligned = alignmask + 1 - (offset & alignmask);
if (nbytes > unaligned)
nbytes = unaligned;
}
walk->entrylen -= nbytes; walk->entrylen -= nbytes;
return nbytes; return nbytes;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册