Repository navigation
fix(app): fix package config change crash and harden config handling - #1648
Merged
Merged
Conversation
Follow-up fixes for the package config rework in bmax121#1592: - app: open the config lock only after Natives.su(); the lock lives in root-only /data/adb/ap, so opening it before elevation always failed with EACCES and crashed changeConfig; degrade to unlocked on failure - app: abort changeConfig when su fails instead of silently doing nothing - app: match the CSV header field-by-field; a data row whose package name is literally "pkg" was swallowed by a startsWith("pkg,") check - apd: treat 0-byte/blank package_config as a legitimately empty config (touch-created on install, writers are atomic, kernel reads 0 bytes as "no entries") instead of a torn read, which stalled every uid event by 5-10s on fresh installs
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The app lock does not coordinate with apd’s writer, allowing concurrent updates to overwrite each other.
1 open finding
What changed in this PR
Hardens package configuration parsing, privilege handling, locking, and empty-config behavior.
Changes:
- Validates CSV headers field-by-field.
- Elevates before locking and aborts when elevation fails.
- Treats blank package configs as valid empty configurations.
| File | Description |
|---|---|
PkgConfig.kt |
Improves header parsing and privileged lock handling. |
package.rs |
Accepts zero-byte and blank configs as valid empty states. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+126
to
+127
| val lock = try { | ||
| r.channel.lock() |
Address review feedback on the package config lock: - synchronize_package_uid(): take the same fcntl record lock the app uses around the whole read-modify-write. Java FileChannel.lock() is a POSIX fcntl lock, so flock(2) would not exclude the app; fail-open on lock errors, mirroring the app - write_ap_package_config(): fsync the temp file before rename (the app already does), so a crash right after the rename cannot leave a truncated config
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.

Follow-up fixes for the package config rework in #1592: