Commit 23a75eee070f1370bee803a34f285cf81eb5f331
Committed by
Herbert Xu
1 parent
fc1caf6eaf
Exists in
master
and in
4 other branches
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>
Showing 1 changed file with 5 additions and 2 deletions Side-by-side Diff
crypto/ahash.c
... | ... | @@ -47,8 +47,11 @@ |
47 | 47 | walk->data = crypto_kmap(walk->pg, 0); |
48 | 48 | walk->data += offset; |
49 | 49 | |
50 | - if (offset & alignmask) | |
51 | - nbytes = alignmask + 1 - (offset & alignmask); | |
50 | + if (offset & alignmask) { | |
51 | + unsigned int unaligned = alignmask + 1 - (offset & alignmask); | |
52 | + if (nbytes > unaligned) | |
53 | + nbytes = unaligned; | |
54 | + } | |
52 | 55 | |
53 | 56 | walk->entrylen -= nbytes; |
54 | 57 | return nbytes; |