Skip to content

Commit acdb04d

Browse files
committed
crypto: skcipher - Fix blkcipher walk OOM crash
When we need to allocate a temporary blkcipher_walk_next and it fails, the code is supposed to take the slow path of processing the data block by block. However, due to an unrelated change we instead end up dereferencing the NULL pointer. This patch fixes it by moving the unrelated bsize setting out of the way so that we enter the slow path as inteded. Fixes: 7607bd8 ("[CRYPTO] blkcipher: Added blkcipher_walk_virt_block") Cc: [email protected] Reported-by: xiakaixu <[email protected]> Reported-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Tested-by: Ard Biesheuvel <[email protected]>
1 parent 53a5d5d commit acdb04d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

crypto/blkcipher.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ static int blkcipher_walk_next(struct blkcipher_desc *desc,
233233
return blkcipher_walk_done(desc, walk, -EINVAL);
234234
}
235235

236+
bsize = min(walk->walk_blocksize, n);
237+
236238
walk->flags &= ~(BLKCIPHER_WALK_SLOW | BLKCIPHER_WALK_COPY |
237239
BLKCIPHER_WALK_DIFF);
238240
if (!scatterwalk_aligned(&walk->in, walk->alignmask) ||
@@ -245,7 +247,6 @@ static int blkcipher_walk_next(struct blkcipher_desc *desc,
245247
}
246248
}
247249

248-
bsize = min(walk->walk_blocksize, n);
249250
n = scatterwalk_clamp(&walk->in, n);
250251
n = scatterwalk_clamp(&walk->out, n);
251252

0 commit comments

Comments
 (0)