linux/arch/arm64
Ard Biesheuvel e47705fb81 crypto: arm64/aes-ctr - fix NULL dereference in tail processing
[ Upstream commit 2db34e78f1 ]

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: 49788fe2a1 ("arm64/crypto: AES-ECB/CBC/CTR/XTS using ARMv8 NEON and Crypto Extensions")
Cc: stable@vger.kernel.org
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: Sasha Levin <alexander.levin@verizon.com>
History 2016-10-05 22:40:20 -04:00
..
boot dtb: xgene: fix: Backward compatibility with older firmware 2014-11-04 17:08:42 -05:00
configs arm64: defconfig: update defconfig for 3.18 2014-11-05 17:07:58 +00:00
crypto crypto: arm64/aes-ctr - fix NULL dereference in tail processing 2016-10-05 22:40:20 -04:00
include arm64: spinlocks: implement smp_mb__before_spinlock() as smp_mb() 2016-10-05 22:40:20 -04:00
kernel arm64: debug: unmask PSTATE.D earlier 2016-08-22 12:23:12 -04:00
kvm arm/arm64: KVM: Fix ioctl error handling 2016-03-11 09:45:24 -05:00
lib arm64: __clear_user: handle exceptions on strb 2014-11-13 15:21:26 +00:00
mm arm64: debug: unmask PSTATE.D earlier 2016-08-22 12:23:12 -04:00
net arm64: bpf: fix signedness bug in loading 64-bit immediate 2015-06-10 13:42:27 -04:00
xen arm: xen: implement multicall hypercall support. 2014-04-24 13:09:46 +01:00
Kconfig arm64: errata: add module build workaround for erratum #843419 2015-10-07 10:12:14 -04:00
Kconfig.debug arm64: Add CONFIG_DEBUG_SET_MODULE_RONX support 2014-09-08 14:39:18 +01:00
Makefile arm64: errata: Add -mpc-relative-literal-loads to build flags 2016-04-18 08:49:41 -04:00