Skip to content

Fix key permission selection and lookup - #14597

Open
tamird wants to merge 1 commit into
google:masterfrom
tamird:fix-key-permission-selection
Open

Fix key permission selection and lookup#14597
tamird wants to merge 1 commit into
google:masterfrom
tamird:fix-key-permission-selection

Conversation

@tamird

@tamird tamird commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Key checks accumulate permissions from owner, group, and other classes and ignore supplementary groups. This can grant access that Linux denies or deny a group member access. Select one class using Linux's precedence, including fallback to other when the group mask is empty, then add possessor permissions.

KEYCTL_GET_KEYRING_ID returns positive IDs without validating them, and KEYCTL_SETPERM cannot find a retained session keyring by numeric ID after a user-namespace change. Share key resolution across lookup and permission changes, resolving the session keyring before the current namespace's key map. Keep the permission check for each operation, allowing SETPERM with SETATTR even when SEARCH is absent.

Exercise permission selection, both ID forms, and lookup and permission changes after a user-namespace transition through syscall tests shared by Linux and gVisor.

Assisted-by: Codex

@tamird

tamird commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@konstantin-s-bogom another honest bug here, syscall test included

Comment thread pkg/sentry/kernel/task_key.go Outdated
Key checks combine owner, group, and other permissions and ignore
supplementary groups. Select the owner class first, otherwise a matching
nonempty group class, otherwise other permissions. Add possessor
permissions to the selected class, matching Linux.

KEYCTL_GET_KEYRING_ID returns positive IDs without checking existence or
permissions. Share key resolution across lookups and permission changes
so retained session keyrings remain addressable after user-namespace
transitions. Validate numeric IDs and check SETATTR for KEYCTL_SETPERM
without requiring SEARCH.

Exercise permission selection, both ID forms, and lookup and permission
changes after user-namespace transitions through syscall tests shared by
Linux and gVisor.

Assisted-by: Codex
@tamird
tamird force-pushed the fix-key-permission-selection branch from e5bdc21 to a498081 Compare September 4, 2026 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants