spinlock: handle missing raw-spin symbols for KP-owned locks - #302
Merged
Admirepowered merged 1 commit intoSep 1, 2026
Merged
Conversation
qssn70
force-pushed
the
codex/fix-missing-raw-spinlock-fallback
branch
from
August 31, 2026 11:36
2bb94e3 to
76bb298
Compare
Collaborator
|
If _raw_spin_lock_irqsave is available, please use the unified path,or use no return function |
qssn70
force-pushed
the
codex/fix-missing-raw-spinlock-fallback
branch
from
August 31, 2026 12:24
76bb298 to
b778556
Compare
Contributor
Author
|
Thanks. Updated to use unified irqsave semantics: the helper now uses the native |
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.
Problem
KernelPatch assumes that the generic
_raw_spin_*wrappers always exist ascallable kallsyms symbols. This is not true for kernels that inline their
spinlock wrappers.
When lookup fails, the kfunc pointer remains zero, but the existing
spin_lock()wrapper still calls it unconditionally. On the affected kernel,the first
task_ext_create()lock acquisition branches to address zero beforeAndroid starts.
This was confirmed on Xiaomi Mi MIX 2S (
polaris), Linux 4.9.327, with bothKernelPatch 0.13.5 and 0.13.8.
Confirmed root cause
The tested kernel has:
The extracted kallsyms table contains 137,036 symbols, but none of these:
Only
queued_spin_lock_slowpathandqueued_spin_unlock_waitare present;they are not drop-in replacements for the generic wrappers.
Runtime isolation
The failure was isolated with device-side single-variable builds:
bypass_selinux()boots successfully.task_observer()reproduces the boot failure.prepare_init_ext(init_task), with task hooks unreachable, still fails.completely (
sys.boot_completed=1).This excludes KALLSYMS parsing, the rest-init trampoline, task hooks,
copy_process, and earlier initialization stages as necessary causes.Changes
kp_private_spin_lock()/kp_private_spin_unlock()forzero-initialized, KP-owned locks only.
_raw_spin_lock_irqsave/_raw_spin_unlock_irqrestorepair when both symbols resolve.yieldwhile contended;The generic
linux/spinlock.hAPI is unchanged. The local 0/1 TAS fallback isnot exposed for kernel-owned ticket/qspinlock objects.
Both task-observer and kstorage are covered. Fixing only the first task slot
allocation would allow boot to progress until kstorage reaches the same missing
raw-spin path.
Validation
The affected-device prototype used the same DAIF/TAS fallback and completed
Android boot. The complete KernelPatch 0.13.8 candidate was reported stable
during normal use:
On this kernel, the submitted private-helper refactor selects the same local
fallback backend.
The submitted commit was additionally verified with:
make kpimgusing Arm GNU Toolchain 12.2;make x86;git diff --check;ldxr/stxrcompare/exchange;yieldcontention loop;stlrrelease;helper.
The refactor removes the public-header
asm/atomic.hdependency from theprototype and introduces no new
READ_ONCE/WRITE_ONCEredefinitionwarnings.
Scope
The confirmed root cause applies to the tested Polaris 4.9.327 kernel. Runtime
coverage on other PREEMPT ARM64 configurations remains to be validated.
Possibly related symptom reports: #21 and #301. Neither report contains enough
raw-spin evidence to claim the same root cause.
Related but different work:
emitted.
included here.