Re: [PATCH] keys: reject descriptions that exceed the index length

From: Daehyeon Ko

Date: Fri Aug 28 2026 - 01:38:56 EST


Hi Jarkko,

Thanks. You are right that the commit message should have included the
observed runtime evidence. I had tested the bug, but omitting that evidence
made the report unnecessarily hard to assess. Sorry about that.

No, the exact command above does not crash in my test. I ran it as uid 1000
with no capabilities on the vulnerable v6.12.105 kernel, and it returned
ENOPKG. There are three relevant details:

1. The in-tree X.509 parser does not support an Ed25519 public-key OID.

2. keyctl passes "%:s" as a literal non-empty description. It does not
request a generated description in that argument position. An empty
string is needed; add_key() normalizes that to NULL.

3. On my system, the default OpenSSL configuration adds a Subject Key
Identifier. x509_key_preparse() prefers the SKID over the raw serial, so
that also keeps the generated description short.

I repeated the test with a supported RSA certificate, no SKID, the same
32766-byte positive serial and two-byte subject, and an empty keyctl
description. The keyctl process recorded uid 1000 and zero inheritable,
permitted and effective capabilities, then hit:

kernel BUG at security/keys/keyring.c:1308
__key_link_begin
__key_create_or_update
key_create_or_update
__do_sys_add_key
Kernel panic - not syncing: Fatal exception

For comparison, the same RSA/no-SKID certificate with "%:s" as the explicit
description created the key normally and produced no splat. An RSA
certificate generated with the default SKID also created the key normally,
even with an empty description.

The original source reproducer, which constructs the DER without a SKID,
already produced the registered BUG and panic on 3/3 fresh v6.12.105 KASAN
boots as uid 1000. The 32765-byte-serial control returned EDQUOT without a
splat. With the patch, the boundary returned EINVAL and the control continued
to return EDQUOT on 3/3 fresh boots.

I will send a v2 with this observed trace and the before/after results in the
commit message. The code change is unchanged. I can also provide the source
reproducer privately if useful.

Thanks,
Daehyeon