Skip to content

Clean up daemon and compiler mounts during KernelSU soft reboot - #1012

Open
bartasc4 wants to merge 1 commit into
JingMatrix:masterfrom
bartasc4:fix/ksu-soft-reboot-lifecycle
Open

bartasc4 wants to merge 1 commit into
JingMatrix:masterfrom
bartasc4:fix/ksu-soft-reboot-lifecycle

Conversation

@bartasc4

@bartasc4 bartasc4 commented Oct 17, 2026 •

Copy link
Copy Markdown

KernelSU replays module startup while Vector's detached daemon can survive. Starting another daemon can collide with the survivor and inherit its compiler bind mounts, causing a wrapper to be cached as the stock dex2oat.

This change prepares the next startup in the module scripts:

  • Identify the old daemon by module cwd, executable and private resource-cache mount; stop it and wait for exit without depending on its process name.
  • Detach only visible compiler mounts rooted in this module, including replaced wrapper inodes and stacked mounts. Preserve other modules' mounts.
  • Clean up in emulated-soft-reboot.sh, in post-fs-data.sh for the first update from a version without that hook, and before service.sh starts a replacement. Install both new stage scripts.

The production diff is limited to four shell files. It adds no application hooks, persistent PID markers or SELinux mode changes; non-KernelSU startup and existing daemon arguments are preserved.

Related to #878. This builds on H3XDaemon's lifecycle hook in #914 and ManiaciaChao's stale-mount diagnosis. It is a standalone implementation against master that overlaps #914, not a patch to apply on top of it. #1008 provides a separate compiler recursion guard and remains useful for failures outside this managed restart path.

Validation evidence: Sanitized diagnostic archive (ZIP). Includes selected device log excerpts, host test results, installer checks and the source patch.

Validation and limits
  • 24 Linux integration tests pass under dash, BusyBox ash/applets and mksh, using real isolated processes and bind mounts. Includes repeated replacements, first-update ordering, unrelated-process/mount preservation, and refusing startup on cleanup failure.
  • The real installer installs and verifies both hooks for ARM, ARM64, x86 and x86_64 host fixtures. These fixtures do not establish Android ABI compatibility.
  • Earlier device observation: Android 12/API 31, ARM64, KernelSU Next 3.4.2 and NeoZygisk; one completed emulated cycle, one replacement Vector daemon, stock compiler FDs distinct from wrappers, single compiler bind mounts, IPC reconnection and module loading. The four production scripts are byte-identical to that tested local build.
  • That device build included other local changes and an unrelated environment workaround. This is not a controlled stock-versus-patched comparison. The current upstream-based PR has not been installed on the phone or rebuilt end to end; no all-version or repeated-device-cycle claim is made.
  • A foreign mount covering a Vector mount is deliberately left intact. This does not resolve injection-provider lifecycle bugs or every possible soft-reboot failure.

Reproduce: python3 tests/soft-reboot/run_tests.py (Linux; requirements in tests/soft-reboot/README.md).

Stop surviving Vector daemons and detach their compiler mounts before starting a replacement. Cover the first update before Android restarts, preserve unrelated mounts, and retain the existing service arguments.

Builds on the lifecycle diagnosis in JingMatrix#878 and JingMatrix#914 and the stale compiler mounts reported by ManiaciaChao in JingMatrix#878. Include isolated Linux process/mount regression tests.
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.

1 participant