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: 7e70cb497850 ("keys: add new key-type encrypted")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/keyrings/20260826154456.85974-1-blbllhy@gmail.com/
Assisted-by: GitHub-Copilot:claude-opus-4.6
Signed-off-by: Cen Zhang <redacted>
Signed-off-by: Francis Perron <redacted>
---
Changes in v3:
- Describe the bounds using u16 and U16_MAX and simplify the commit
message.
- Include the KASAN-reported write size.
- Remove organization names from the author and sign-off identities.
- Remove the unnecessary off-list discussion note.
- Use cenzhang@linux.microsoft.com.
- No code changes.
security/keys/encrypted-keys/encrypted.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
From: Jarkko Sakkinen <jarkko@kernel.org> Date: 2026-09-09 23:01:21
On Wed, Sep 09, 2026 at 11:34:33AM -0400, Cen Zhang wrote:
quoted hunk
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: 7e70cb497850 ("keys: add new key-type encrypted")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/keyrings/20260826154456.85974-1-blbllhy@gmail.com/
Assisted-by: GitHub-Copilot:claude-opus-4.6
Signed-off-by: Cen Zhang <redacted>
Signed-off-by: Francis Perron <redacted>
---
Changes in v3:
- Describe the bounds using u16 and U16_MAX and simplify the commit
message.
- Include the KASAN-reported write size.
- Remove organization names from the author and sign-off identities.
- Remove the unnecessary off-list discussion note.
- Use cenzhang@linux.microsoft.com.
- No code changes.
security/keys/encrypted-keys/encrypted.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
From: R Nageswara Sastry <hidden> Date: 2026-09-10 04:45:23
On 09.09.2026 9:04 PM, Cen Zhang wrote:
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: 7e70cb497850 ("keys: add new key-type encrypted")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/keyrings/20260826154456.85974-1-blbllhy@gmail.com/
Assisted-by: GitHub-Copilot:claude-opus-4.6
Signed-off-by: Cen Zhang <redacted>
Signed-off-by: Francis Perron <redacted>
Tested-by: R Nageswara Sastry <redacted>
System: ppc64le LPAR (IBM POWER), Linux 7.3-rc2
quoted hunk
---
Changes in v3:
- Describe the bounds using u16 and U16_MAX and simplify the commit
message.
- Include the KASAN-reported write size.
- Remove organization names from the author and sign-off identities.
- Remove the unnecessary off-list discussion note.
- Use cenzhang@linux.microsoft.com.
- No code changes.
security/keys/encrypted-keys/encrypted.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
From: Jarkko Sakkinen <jarkko@kernel.org> Date: 2026-09-18 01:31:35
On Thu, Sep 10, 2026 at 10:14:57AM +0530, R Nageswara Sastry wrote:
On 09.09.2026 9:04 PM, Cen Zhang wrote:
quoted
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: 7e70cb497850 ("keys: add new key-type encrypted")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/keyrings/20260826154456.85974-1-blbllhy@gmail.com/
Assisted-by: GitHub-Copilot:claude-opus-4.6
Signed-off-by: Cen Zhang <redacted>
Signed-off-by: Francis Perron <redacted>
Tested-by: R Nageswara Sastry <redacted>
System: ppc64le LPAR (IBM POWER), Linux 7.3-rc2
quoted
---
Changes in v3:
- Describe the bounds using u16 and U16_MAX and simplify the commit
message.
- Include the KASAN-reported write size.
- Remove organization names from the author and sign-off identities.
- Remove the unnecessary off-list discussion note.
- Use cenzhang@linux.microsoft.com.
- No code changes.
security/keys/encrypted-keys/encrypted.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)