linux/security/keys
Cen Zhang 8697c431e2 KEYS: encrypted: fix integer overflow of datablob_len
encrypted_key_alloc() stores datablob_len in a u16. It is computed from
multiple string and payload lengths. If the result exceeds U16_MAX, the
assignment truncates the allocation size. KASAN reports a 32760-byte
slab-out-of-bounds write when __ekey_init() copies the master key
description into the undersized buffer.

The total payload length stored in key->datalen is also a u16. Use
check_add_overflow() to reject values that do not fit either destination,
and use kzalloc_flex() for the flexible-array allocation.

Fixes: 7e70cb4978 ("keys: add new key-type encrypted")
Cc: stable@vger.kernel.org
Assisted-by: GitHub-Copilot:claude-opus-4.6
Signed-off-by: Cen Zhang <cenzhang@linux.microsoft.com>
Signed-off-by: Francis Perron <francis@akrites.dev>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Tested-by: R Nageswara Sastry <rnsastry@linux.ibm.com>
Link: https://lore.kernel.org/r/20260909153433.83117-1-cenzhang@linux.microsoft.com
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
2026-09-12 00:43:45 +03:00
..
encrypted-keys KEYS: encrypted: fix integer overflow of datablob_len 2026-09-12 00:43:45 +03:00
trusted-keys KEYS: trusted: Fix tpm2_load_cmd() boundary check 2026-09-12 00:43:45 +03:00
big_key.c mm: update shmem_[kernel]_file_*() functions to use vma_flags_t 2026-02-12 15:42:58 -08:00
compat_dh.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
compat.c security/keys: remove compat_keyctl_instantiate_key_iov 2020-10-03 00:02:16 -04:00
dh.c KEYS: DH: Use crypto_wait_req 2023-02-13 18:34:48 +08:00
gc.c keys: fix lost wakeup when reaping a dead key type 2026-09-12 00:43:45 +03:00
internal.h keys: Pin request_key_auth payload in instantiate paths 2026-06-15 15:19:13 +03:00
Kconfig KEYS: encrypted: Remove unnecessary selection of CRYPTO_RNG 2026-06-15 15:19:12 +03:00
key.c keys: prevent slab cache merging for key_jar 2026-06-15 15:19:13 +03:00
keyctl_pkey.c keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP 2026-06-15 15:19:13 +03:00
keyctl.c keys: Pin request_key_auth payload in instantiate paths 2026-06-15 15:19:13 +03:00
keyring.c keys: make keyring key-chunk byte order agree with keyring_diff_objects() 2026-07-23 18:23:39 +03:00
Makefile KEYS: remove CONFIG_KEYS_COMPAT 2019-12-12 23:41:17 +02:00
permission.c keys: Make the KEY_NEED_* perms an enum rather than a mask 2020-05-19 15:42:22 +01:00
persistent.c Revert "Merge tag 'keys-acl-20190703' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs" 2019-07-10 18:43:43 -07:00
proc.c keys, dns: Allow key types (eg. DNS) to be reclaimed immediately on expiry 2023-12-21 13:47:38 +00:00
process_keys.c cred: make init_cred static 2025-11-04 12:36:02 +01:00
request_key_auth.c keys: translate request_key_auth pid for the reading procfs instance 2026-09-12 00:43:45 +03:00
request_key.c keys: request_key: replace BUG with return -EINVAL 2026-06-15 15:19:13 +03:00
sysctl.c treewide: const qualify ctl_tables where applicable 2025-01-28 13:48:37 +01:00
user_defined.c keys: use kmalloc_flex in user_preparse 2026-06-15 15:19:12 +03:00