Skip to content

Commit 13f4bb7

Browse files
committed
crypto: hash - Fix page length clamping in hash walk
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. Cc: <[email protected]> Reported-by: Steffen Klassert <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 6dc5df7 commit 13f4bb7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

crypto/ahash.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk)
6969
struct scatterlist *sg;
7070

7171
sg = walk->sg;
72-
walk->pg = sg_page(sg);
7372
walk->offset = sg->offset;
73+
walk->pg = sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT);
74+
walk->offset = offset_in_page(walk->offset);
7475
walk->entrylen = sg->length;
7576

7677
if (walk->entrylen > walk->total)

0 commit comments

Comments
 (0)