ksyms: bound credential and task structure scans - #312
Open
xeropresence wants to merge 1 commit into
Open
xeropresence wants to merge 1 commit into
xeropresence wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Keep credential/task offset probes inside their scan buffers and bound the ambient-capability comparison by the kernel-allocated credential's size.
Problem
Several offset-discovery loops advance in four-byte steps but read a
kernel_cap_tor pointer. Testing only the starting offset allows the final load to extend beyond the configured scan boundary.The ambient-capability probe has another boundary: after
cap_task_prctl, the task can reference a slab-allocated credential rather than theCRED_MAX_SIZEscratch buffer. Scanning that object as though it were the full scratch-buffer size can read past the allocation. On hardware-tagged KASAN kernels configured to panic on a fault, this is a boot failure rather than a harmless speculative probe.Changes
ksizefor the newly installed credential and bound the ambient-capability comparison by both that size andCRED_MAX_SIZE.ksizecannot be resolved, retain the existing fixed scan limit rather than introducing a new boot prerequisite.The patch does not hardcode GrapheneOS structure offsets or randomization seeds, disable KASAN/RANDSTRUCT, or change the persistent preset format. It also does not claim to make every unrelated structure probe allocation-aware.
Verification
Built the Android ARM64 payload and
kptoolson this branch.Device testing used all three fixes on KernelPatch
0.13.8, with a Pixel 8 running GrapheneOS2026081300:CONFIG_RANDSTRUCT_FULLand hardware-tagged KASAN enabled.