Skip to content

ADFA-5362 fix(proot): learn per device that a kernel cannot run proot with seccomp - #513

Merged
luisguzman-adfa merged 3 commits into
mainfrom
fix/ADFA-5362-proot-seccomp-capability
Sep 1, 2026
Merged

luisguzman-adfa merged 3 commits into
mainfrom
fix/ADFA-5362-proot-seccomp-capability

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

What

Some kernels cannot run proot with its seccomp acceleration: proot aborts in well under a second and the device never starts. The app now learns that from a real launch, remembers it per device, and launches accordingly. Healthy devices are untouched.

Why not just set PROOT_NO_SECCOMP everywhere

Measured on a healthy device (kernel 4.14), same rootfs, two passes each:

workload seccomp no seccomp cost
metadata walk (73 616 files) 20.4 s 24.1 s +18 %
read-heavy pass 3.8 s 6.6 s +75 %

Why no probe

A trivial probe (/bin/true) does not reproduce the abort — it exits 0 on the affected device. A faithful probe has to be the production shape (bash -l), and a successful one costs ~3 s on a fast device and ~13.6 s on a slow one, paid by every healthy device for an answer the real launch gives for free. The failure is the cheap half: exit 1 in ~0.4 s carrying proot's own marker. So the exit seam reads the marker; nothing extra is ever launched.

How

  • SeccompFailure — non-zero exit and proot's own marker. Marker-based on purpose: proot names this failure itself, so there is no timing heuristic that could misread a failing install and slow the device down for good.
  • CapabilityKey — a stored verdict only counts under the same OS build + kernel + versionCode. That is what makes the cache safe over time, and why nothing ever has to clear it.
  • ProotEnvironment — one builder for the proot environment, replacing two hand-written copies. The generated iiab CLI consumes the same verdict.
  • Nothing relaunches inside the engine. The reconciler already relaunches whenever the environment is not alive, and picks up the new mode on its next tick (device-measured: 2.3 s).

Reduction

before after
copies of the proot environment block 2 1
probe subsystem (runner, workload, isolation) — none built
actuation paths that relaunch 1 1 (unchanged)
new facts, with one owner and an invalidation key — 1

Device verification

affected device (kernel 3.18) healthy device (kernel 4.14)
detections 1, then never again 0
verdict stored yes, with the full key none written
proot launches aborts once, recovers in 2.3 s 1, no extra process
live environment PROOT_NO_SECCOMP=1 no seccomp variable
generated iiab CLI carries the export —
survives process restart yes, 0 re-detections n/a
box readiness see "Not fixed here" HTTP 200, no regression

Not fixed here

The affected device still does not stay up: it now launches proot correctly and is then killed mid-boot, because a legitimate 37 s boot meets a 20 s service-down grace. That is ADFA-5365 (boot grace vs flap grace). This PR closes the capability half only.

Test plan

  • ./gradlew :app:testDebugUnitTest :app:lintDebug — green.
  • On a healthy device: no ProotCapabilityPrefs.xml is created, the live proot has no seccomp variable, the box serves normally.
  • On an affected device: logcat | grep ADFA-5362 shows exactly one learning line; the next launch carries PROOT_NO_SECCOMP=1; shared_prefs/ProotCapabilityPrefs.xml holds the verdict and the key.

No server change, no new strings, no UI change.

…place

PRootEngine wrote the same environment block twice, so a per-device launch
decision had no single place to land. Extract it into ProotEnvironment,
applied identically by both launch methods.

No behaviour change: the map is value-identical to what shipped, pinned by
ProotEnvironmentTest so drift fails a test instead of a device.
… seccomp

Some kernels cannot run proot with its seccomp acceleration: it aborts in well
under a second on assertion "IS_IN_SYSENTER(tracee)" failed, and the device
never starts. Forcing PROOT_NO_SECCOMP everywhere instead costs +18% to +75%,
so the fact has to be learned per device.

No probe: a trivial one does not reproduce the abort, and a faithful one costs
3-14s on every healthy device for an answer the real launch gives for free.
Instead the exit seam recognises proot's own marker, remembers it against a
capability key (OS build, kernel, app version) and relaunches once. The abort
lands before the guest does any work, so the retry cannot duplicate anything
and the caller still sees a single onProcessExit.
…capability key

Code review: relaunching from inside the engine was a second actuation path
that never consulted `desired`, so a stop landing between the aborted launch
and the relaunch would have been overruled. The reconciler already relaunches
whenever the environment is not alive, so the engine now only records the
verdict. Device-verified: recovery takes one tick, 2.3s.

The rule that a stored verdict only counts under the same capability key is
what keeps a healthy device from being left permanently slower, and it lived
in the data layer with no test. Moved to domain as CapabilityKey, with the
cases that matter: OS update, kernel change, new versionCode, nothing stored.
@luisguzman-adfa
luisguzman-adfa merged commit 3a1638f into main Sep 1, 2026
3 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the fix/ADFA-5362-proot-seccomp-capability branch September 1, 2026 09:51
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