Repository navigation
kabi: keep keyring index identities private - #2268
Conversation
Reviewer's GuideData structuresRestore the frozen public structure layouts by removing index identities and cached IDs from key types, tags, index keys, and keys.
Add private identity and per-key index records backed by reference-counted XArrays, and adjust search context to carry a private lookup key.
APIChange the internal link-begin interface to receive the key when available, enabling reuse of its published private index.
Uses of the APIUpdate key allocation, linking, construction, and movement callers to use private-index allocation and the revised link-begin interface.
ImplementationManage identity references and private per-key index allocation, hashing, lookup, and destruction while preserving address-independent ordering.
Release private key indexes during key garbage collection.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="security/keys/keyring.c" line_range="152" />
<code_context>
+ const struct keyring_index_key *key)
+{
+ memset(index, 0, sizeof(*index));
+ index->key = *key;
+ if (!index->key.domain_tag) {
+ if (index->key.type->flags & KEY_TYPE_NET_DOMAIN)
</code_context>
<issue_to_address>
**Existing keys are missed**
When a direct search or update lookup uses a nonempty description prefix whose inline index bytes are not populated, `keyring_index_lookup()` copies the caller’s index key without finalizing its description prefix, and `hash_key_type_and_desc()` only sets the hash. The associative-array lookup compares a different `x` chunk from the one stored for the key, so direct searches and update lookups miss existing keys.
Finalize the description prefix in the index key before the associative-array lookup.
</issue_to_address>There was a problem hiding this comment.
🟡 Changes recommended
A link delayed across type teardown can prepare an edit using the wrong type identities, placing the key on the wrong tree path and breaking lookup or unlink.
3 open issues
What changed in this PR
This PR restores the frozen public key structure layouts while preserving address-independent keyring ordering. It moves index identities and their lifetime management into private storage.
Changes:
- Remove identity fields from public key, key-type, domain, and index structures.
- Use private, reference-counted XArrays for identities, per-key indexes, and link-edit indexes.
- Adapt searches, linking, allocation, and cleanup to use private indexes.
| File | Description |
|---|---|
security/keys/keyring.c |
Implements private identities and indexes for searches and link operations. |
security/keys/key.c |
Allocates private indexes and adds error-path cleanup. |
security/keys/internal.h |
Declares index lifecycle helpers and private search-context storage. |
security/keys/gc.c |
Releases private indexes during key destruction. |
include/linux/key.h |
Removes identity fields to restore public structure layouts. |
include/linux/key-type.h |
Removes the public key-type identity field. |
Review effort: Balanced
deepin inclusion category: kabi Restore the frozen key_type, key_tag, keyring_index_key and key layouts while retaining address-independent keyring ordering. Store type and domain identities and per-key indexes in private, reference-counted XArrays instead of extending public structures. Direct RCU lookups borrow existing identities without allocating. Existing keys also reuse their published indexes for link edits, keeping edit preparation, insertion and unlink on the original tree path across type unregister and domain teardown. Only an edit prepared before key allocation owns a temporary index, which is carried in the edit leaf pointer. Finalize inline descriptions in private lookup keys so direct searches see the same chunks as published indexes. Route private-index allocation failures through the description cleanup path. Fixes: ab9e532 ("keys: make keyring indexes independent of kernel addresses") Signed-off-by: shaoyang <shaoyang@uniontech.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
ff6ec8c to
3c110f4
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Changes to keyring leaf representation and identity ownership require specialized human review, RCU/refcount stress testing, and frozen-ABI validation across x86_64/aarch64, including CONFIG_KEYP, that static inspection cannot provide.
No open issues 🎉
3 resolved since last review
Review effort: Balanced


Restore the frozen key_type, key_tag, keyring_index_key and key layouts while retaining address-independent keyring ordering. Store type and domain identities and per-key indexes in private, reference-counted XArrays instead of extending public structures.
Direct RCU lookups borrow existing identities without allocating, while key publication and link edits own the references needed across type unregister and domain teardown.
Fixes: ab9e532 ("keys: make keyring indexes independent of kernel addresses")
Summary by Sourcery
Keep keyring index identities private without expanding public key structures or changing address-independent ordering.
Bug Fixes:
Enhancements: