linux/arch/x86/crypto
Mohamad Raizudeen 226154ea87 crypto: x86/aes-gcm - fix always true check for last AAD segment
In gcm_process_assoc(), a segment that is not the last one must have its
length rounded down to a multiple of 16 bytes, as required by the
assembly. The check for a non-last segment is `if (unlikely(assoclen))
/* Not the last segment yet? */` where assoclen is the number of AAD
bytes remaining after the current segment.

Since the conversion to the new scatterwalk API, assoclen is decremented
at the end of the loop body rather than the beginning, so it still
includes the current segment when the check executes, making the check
always true.

As a result the last segment was rounded down as well, causing some
avoidable extra work: an additional memcpy into the temporary buffer and
an additional call into the assembly after the loop. The GCM
authentication tag is unaffected either way, so the self-tests pass and
this went unnoticed. It is purely an efficiency issue rather than a
correctness one.

Fix this by moving the assoclen decrement back to the beginning of the
loop body.

Fixes: e9787deff4 ("crypto: x86/aes-gcm - use the new scatterwalk functions")
Cc: stable@vger.kernel.org
Suggested-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Mohamad Raizudeen <raizudeen.kerneldev@gmail.com>
Link: https://patch.msgid.link/20260926145903.6061-1-raizudeen.kerneldev@gmail.com
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
History 2026-09-29 15:28:42 -07:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
aegis128-aesni-asm.S crypto: x86/aegis128 - remove unneeded RETs 2024-10-28 18:33:10 +08:00
aegis128-aesni-glue.c crypto: x86/aegis - Add missing error checks 2025-07-18 20:51:59 +10:00
aes-ctr-avx-x86_64.S crypto: x86 - Remove CONFIG_AS_VPCLMULQDQ 2025-08-21 14:32:41 +02:00
aes-gcm-aesni-x86_64.S crypto: x86/aes-gcm - Use new AES library API 2026-01-15 14:09:08 -08:00
aes-gcm-vaes-avx2.S crypto: x86/aes-gcm - Use new AES library API 2026-01-15 14:09:08 -08:00
aes-gcm-vaes-avx512.S crypto: x86/aes-gcm - Use new AES library API 2026-01-15 14:09:08 -08:00
aes-xts-avx-x86_64.S crypto: x86 - Remove CONFIG_AS_VPCLMULQDQ 2025-08-21 14:32:41 +02:00
aesni-intel_asm.S crypto: x86/aes - Remove the superseded AES-NI crypto_cipher 2026-01-15 14:09:07 -08:00
aesni-intel_glue.c crypto: x86/aes-gcm - fix always true check for last AAD segment 2026-09-29 15:28:42 -07:00
aria-aesni-avx-asm_64.S crypto: x86 - Remove CONFIG_AS_GFNI 2025-08-20 20:48:07 +02:00
aria-aesni-avx2-asm_64.S crypto: x86/aria - add missing vzeroupper in AVX2 code 2026-09-04 18:45:50 +10:00
aria-avx.h crypto: x86/aria - implement aria-avx512 2023-01-06 17:15:47 +08:00
aria-gfni-avx512-asm_64.S crypto: x86/aria - add missing vzeroupper in AVX-512 code 2026-09-04 18:45:51 +10:00
aria_aesni_avx2_glue.c crypto: x86 - Remove CONFIG_AS_GFNI 2025-08-20 20:48:07 +02:00
aria_aesni_avx_glue.c crypto: x86 - Remove CONFIG_AS_GFNI 2025-08-20 20:48:07 +02:00
aria_gfni_avx512_glue.c crypto: x86/aria - stop using the SIMD helper 2025-04-07 13:22:27 +08:00
blowfish-x86_64-asm_64.S crypto: x86/blowfish - Eliminate use of SYM_TYPED_FUNC_START in asm 2023-02-10 17:20:19 +08:00
blowfish_glue.c crypto: x86 - remove assignments of 0 to cra_alignmask 2024-12-14 17:21:44 +08:00
camellia-aesni-avx-asm_64.S x86,kcfi: Fix EXPORT_SYMBOL vs kCFI 2025-02-14 10:32:05 +01:00
camellia-aesni-avx2-asm_64.S x86,kcfi: Fix EXPORT_SYMBOL vs kCFI 2025-02-14 10:32:05 +01:00
camellia-x86_64-asm_64.S x86,kcfi: Fix EXPORT_SYMBOL vs kCFI 2025-02-14 10:32:05 +01:00
camellia.h crypto: x86 - use local headers for x86 specific shared declarations 2021-01-14 17:10:30 +11:00
camellia_aesni_avx2_glue.c crypto: x86/camellia - stop using the SIMD helper 2025-04-07 13:22:27 +08:00
camellia_aesni_avx_glue.c crypto: x86 - Fix build warnings about export.h 2025-06-23 16:59:38 +08:00
camellia_glue.c crypto: x86 - Fix build warnings about export.h 2025-06-23 16:59:38 +08:00
cast5-avx-x86_64-asm_64.S crypto: x86/cast5 - Remove unused cast5_ctr_16way 2024-10-10 17:08:02 +08:00
cast5_avx_glue.c crypto: x86/cast - stop using the SIMD helper 2025-04-07 13:22:27 +08:00
cast6-avx-x86_64-asm_64.S crypto: x86/cast6 - Use RIP-relative addressing 2023-04-20 18:20:04 +08:00
cast6_avx_glue.c crypto: x86/cast - stop using the SIMD helper 2025-04-07 13:22:27 +08:00
ecb_cbc_helpers.h crypto: x86 - exit fpu context earlier in ECB/CBC macros 2023-02-03 12:54:54 +08:00
glue_helper-asm-avx.S crypto: x86/glue-helper - drop CTR helper routines 2021-01-14 17:10:28 +11:00
glue_helper-asm-avx2.S crypto: x86/glue-helper - drop CTR helper routines 2021-01-14 17:10:28 +11:00
Kconfig This update includes the following changes: 2026-04-15 15:22:26 -07:00
Makefile This update includes the following changes: 2026-04-15 15:22:26 -07:00
serpent-avx-x86_64-asm_64.S x86,kcfi: Fix EXPORT_SYMBOL vs kCFI 2025-02-14 10:32:05 +01:00
serpent-avx.h crypto: x86 - use local headers for x86 specific shared declarations 2021-01-14 17:10:30 +11:00
serpent-avx2-asm_64.S crypto: x86/serpent: Remove redundant alignments 2022-10-17 16:41:01 +02:00
serpent-sse2-i586-asm_32.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
serpent-sse2-x86_64-asm_64.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
serpent-sse2.h crypto: x86 - use local headers for x86 specific shared declarations 2021-01-14 17:10:30 +11:00
serpent_avx2_glue.c crypto: x86/serpent - stop using the SIMD helper 2025-04-07 13:22:27 +08:00
serpent_avx_glue.c crypto: x86 - Fix build warnings about export.h 2025-06-23 16:59:38 +08:00
serpent_sse2_glue.c crypto: x86/serpent - stop using the SIMD helper 2025-04-07 13:22:27 +08:00
sm4-aesni-avx-asm_64.S crypto: x86/sm4 - Remove cfb(sm4) 2023-12-08 11:59:45 +08:00
sm4-aesni-avx2-asm_64.S crypto: x86/sm4 - Remove cfb(sm4) 2023-12-08 11:59:45 +08:00
sm4-avx.h crypto: x86/sm4 - Remove cfb(sm4) 2023-12-08 11:59:45 +08:00
sm4_aesni_avx2_glue.c crypto: x86/sm4 - stop using the SIMD helper 2025-04-07 13:22:27 +08:00
sm4_aesni_avx_glue.c crypto: x86 - Fix build warnings about export.h 2025-06-23 16:59:38 +08:00
twofish-avx-x86_64-asm_64.S crypto: twofish: Remove redundant alignments 2022-10-17 16:41:03 +02:00
twofish-i586-asm_32.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
twofish-x86_64-asm_64-3way.S x86,kcfi: Fix EXPORT_SYMBOL vs kCFI 2025-02-14 10:32:05 +01:00
twofish-x86_64-asm_64.S x86,kcfi: Fix EXPORT_SYMBOL vs kCFI 2025-02-14 10:32:05 +01:00
twofish.h crypto: x86 - use local headers for x86 specific shared declarations 2021-01-14 17:10:30 +11:00
twofish_avx_glue.c crypto: x86/twofish - stop using the SIMD helper 2025-04-07 13:22:27 +08:00
twofish_glue.c crypto: x86 - Fix build warnings about export.h 2025-06-23 16:59:38 +08:00
twofish_glue_3way.c crypto: x86 - Fix build warnings about export.h 2025-06-23 16:59:38 +08:00