linux/arch
Herbert Xu 4e4a08868f crypto: arm64/sm4-gcm - Fix possible crash in GCM cryption
An often overlooked aspect of the skcipher walker API is that an
error is not just indicated by a non-zero return value, but by the
fact that walk->nbytes is zero.

Thus it is an error to call skcipher_walk_done after getting back
walk->nbytes == 0 from the previous interaction with the walker.

This is because when walk->nbytes is zero the walker is left in
an undefined state and any further calls to it may try to free
uninitialised stack memory.

The sm4 arm64 ccm code gets this wrong and ends up calling
skcipher_walk_done even when walk->nbytes is zero.

This patch rewrites the loop in a form that resembles other callers.

Reported-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Fixes: ae1b83c7d5 ("crypto: arm64/sm4 - add CE implementation for GCM mode")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Tested-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2023-02-10 17:20:19 +08:00
..
alpha MM patches for 6.2-rc1. 2022-12-13 19:29:45 -08:00
arc MM patches for 6.2-rc1. 2022-12-13 19:29:45 -08:00
arm ARM: dts: aspeed: Add ACRY/AHBC device controller node 2023-01-13 12:11:18 +08:00
arm64 crypto: arm64/sm4-gcm - Fix possible crash in GCM cryption 2023-02-10 17:20:19 +08:00
csky arch/csky patches for 6.2-rc1 2022-12-19 07:51:30 -06:00
hexagon MM patches for 6.2-rc1. 2022-12-13 19:29:45 -08:00
ia64 - Add the call depth tracking mitigation for Retbleed which has 2022-12-14 15:03:00 -08:00
loongarch LoongArch changes for v6.2 2022-12-19 08:23:27 -06:00
m68k m68k: remove broken strcmp implementation 2022-12-21 08:56:43 -08:00
microblaze MM patches for 6.2-rc1. 2022-12-13 19:29:45 -08:00
mips Fixes due to DT changes 2022-12-23 10:49:45 -08:00
nios2 MM patches for 6.2-rc1. 2022-12-13 19:29:45 -08:00
openrisc MM patches for 6.2-rc1. 2022-12-13 19:29:45 -08:00
parisc parisc architecture fixes for kernel v6.2-rc1: 2022-12-20 08:43:53 -06:00
powerpc crypto: p10-aes-gcm - Revert implementation 2023-01-18 17:07:19 +08:00
riscv KVM/riscv changes for 6.2 2022-12-21 18:52:15 -08:00
s390 crypto: s390/aes - drop redundant xts key check 2023-01-06 17:15:47 +08:00
sh treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
sparc MM patches for 6.2-rc1. 2022-12-13 19:29:45 -08:00
um New Feature: 2022-12-17 14:06:53 -06:00
x86 crypto: x86/blowfish - Eliminate use of SYM_TYPED_FUNC_START in asm 2023-02-10 17:20:19 +08:00
xtensa MM patches for 6.2-rc1. 2022-12-13 19:29:45 -08:00
.gitignore
Kconfig arm64 fixes for -rc1 2022-12-16 13:46:41 -06:00