]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
crypto: arm64/aes-ctr - fix NULL dereference in tail processing
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 13 Sep 2016 08:48:53 +0000 (09:48 +0100)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 20 Oct 2016 13:05:54 +0000 (08:05 -0500)
commita67d4fddeed66b5af05ddd0aa9a85d4d76546fc0
tree1171a0eb5d66b9042f0702e3f9ace8d8c6c3e441
parent6d88140f0cc45e5f67872d00ee125fb0ef9dbacc
crypto: arm64/aes-ctr - fix NULL dereference in tail processing

BugLink: http://bugs.launchpad.net/bugs/1629386
commit 2db34e78f126c6001d79d3b66ab1abb482dc7caa upstream.

The AES-CTR glue code avoids calling into the blkcipher API for the
tail portion of the walk, by comparing the remainder of walk.nbytes
modulo AES_BLOCK_SIZE with the residual nbytes, and jumping straight
into the tail processing block if they are equal. This tail processing
block checks whether nbytes != 0, and does nothing otherwise.

However, in case of an allocation failure in the blkcipher layer, we
may enter this code with walk.nbytes == 0, while nbytes > 0. In this
case, we should not dereference the source and destination pointers,
since they may be NULL. So instead of checking for nbytes != 0, check
for (walk.nbytes % AES_BLOCK_SIZE) != 0, which implies the former in
non-error conditions.

Fixes: 49788fe2a128 ("arm64/crypto: AES-ECB/CBC/CTR/XTS using ARMv8 NEON and Crypto Extensions")
Reported-by: xiakaixu <xiakaixu@huawei.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
arch/arm64/crypto/aes-glue.c