Scope analysis loggers to the firmware process subtree - #870
Merged
Conversation
lacraig2
force-pushed
the
workspace/fixanalysis
branch
from
June 25, 2026 13:12
ef8f32a to
209eedf
Compare
lacraig2
force-pushed
the
scope-analysis-loggers
branch
from
June 25, 2026 13:12
a5a17e7 to
e3b9569
Compare
Per-process analysis loggers captured every process from boot, including
Penguin's own infrastructure (boot machinery and the backgrounded vpnguin/
console/guesthopper helpers that run the whole guest lifetime). Scope analysis
to the firmware-under-analysis subtree instead.
init.sh runs the real guest init in a fresh UTS namespace (unshare -u, with a
CONFIG_UTS_NS fallback), so the firmware subtree lives outside the kernel's
initial namespace while Penguin infrastructure stays in it. The igloo_driver
gates syscall/exec/bind hypercall emission on that distinction, which
auto-scopes every logger fed by those hypercalls.
- core/scope.py (new): enables driver-side gating when core.analysis_scope is
set; exposes plugins.scope.in_scope(pid), tracking in-scope pids from the
(now driver-gated) exec_event stream.
- apis/syscalls.py: new scope_filter param on syscall(), defaulting to a hook's
read_only value and plumbed into the kernel hook's scope_filter_enabled. So
read-only logging hooks auto-scope; interventions are unaffected.
- hyper/shell.py: replace the ad-hoc '/igloo/' path filter with a principled
plugins.scope.in_scope(pid) gate (lineage-correct, not path-based).
- analysis/{ficd,interfaces}, apis/execs, loggers/rw_logger: opt into
scope_filter=True (they don't pass read_only).
- penguin_config/structure.py: add core.analysis_scope (default true); set
false to capture every process for debugging.
- defaults.py: enable the scope plugin by default.
env.py is intentionally left unscoped: its getenv/strstr hypercalls come from
the libnvram LD_PRELOAD shim, which lib_inject injects only into firmware
binaries, so it is already firmware-scoped by construction.
Depends on the igloo_driver scope change (scope_filter_enabled hook field +
set_scope_enabled portal op + igloo_in_scope gating).
Generalize core.analysis_scope from a bool to a string so its meaning can evolve without a schema change. Recognized values: 'firmware' (default; scope to the firmware subtree), 'none' (capture everything), and 'infra' (reserved for the inverted 'only Penguin's tools' interpretation). Booleans still validate for backward compatibility (true=='firmware', false=='none'); scope.py normalizes them at load. Bump IGLOO_DRIVER_VERSION to 0.0.85, which ships the scope-gating driver support (igloo_driver #84) this branch depends on.
lacraig2
force-pushed
the
scope-analysis-loggers
branch
from
June 26, 2026 12:56
e3b9569 to
7e9e36d
Compare
Previously scope_filter defaulted to a hook's read_only value, so only logging hooks auto-scoped while interventions ran for every process. Flip the default: any hook added in a default context is meant to analyze or affect the firmware-under-analysis, not Penguin's own plumbing, so all hooks now scope to the firmware subtree by default. The portal transport (sendto PORTAL_MAGIC) must keep running for infra -- it carries init.sh's readiness signal and scope.py's own enable -- so it opts out with scope_filter=False. The explicit scope_filter=True markers on execs/rw_logger/ficd/interfaces are now the default and dropped. Tests exercise Penguin infrastructure, so the unit-test fixtures set core.analysis_scope: none to observe every process.
2 tasks
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
Per-process analysis loggers (shell coverage, syscalls, read/write, exec, binds, …) capture every process from boot — including Penguin's own infrastructure: the boot/init machinery and the backgrounded
vpnguin/console/guesthopperhelpers that run for the entire guest lifetime. The boundary we want is process attribution (the firmware-under-analysis subtree), not a temporal cutoff — a readiness gate can't exclude vpnguin, which runs the whole time.bb_covalready hinted at this with a fragile, shell-onlyfilename.startswith("/igloo/")filter; this replaces it with one principled mechanism covering all loggers.Mechanism: inherited UTS-namespace marker, anchored on the initial namespace
init.shruns the real guest init in a fresh UTS namespace at handoff (unshare -u, with aCONFIG_UTS_NSfallback so boot can't break). The firmware subtree inherits that namespace across fork/exec, so it lives outside the kernel's initial namespace while all Penguin infrastructure stays in it (includingcall_usermodehelperspawns). The igloo_driver gates syscall/exec/bind hypercall emission oncurrent's namespace, which auto-scopes every logger fed by those hypercalls. Anchoring on the initial namespace means firmware that re-unshares its own namespace stays in scope.Changes
pyplugins/core/scope.py(new) — enables driver-side gating whencore.analysis_scopeis set (via theset_scope_enabledportal op), early enough to also exclude pre-handoff boot machinery. Exposesplugins.scope.in_scope(pid), tracking in-scope pids from the (now driver-gated)exec_eventstream.pyplugins/apis/syscalls.py— newscope_filterparam onsyscall(), defaulting to a hook'sread_onlyvalue and plumbed into the kernel hook'sscope_filter_enabled. Read-only logging hooks auto-scope; intervention hooks are unaffected.pyplugins/hyper/shell.py— replace the ad-hoc/igloo/path filter with a lineage-correctplugins.scope.in_scope(pid)gate.pyplugins/{apis/execs,loggers/rw_logger,analysis/ficd,analysis/interfaces}.py— opt intoscope_filter=True(they don't passread_only).syscalls_loggeralready auto-scopes viaread_only=True.src/resources/init.sh— handoff →exec /igloo/utils/busybox unshare -u "${igloo_init}".src/penguin/penguin_config/structure.py(+ regenerateddocs/schema_doc.md) —core.analysis_scope(default true; set false to capture every process for debugging).src/penguin/defaults.py— enable thescopeplugin by default.env.pyis intentionally left unscoped: its getenv/strstr hypercalls come from thelibnvramLD_PRELOAD shim, whichlib_injectinjects only into firmware binaries, so it is already firmware-scoped by construction.Testing
pengimage (with the matching igloo_driver change) boots and runs the fulltest_target(rc 0) with scoping enabled; every logger subtest passes (netbinds, netbinds_lifecycle, env_cmp, env_unset, …), confirming in-scope firmware processes are still captured and theunsharedoesn't break boot. The only failing subtest (indiv_debug+gdbserver) fails identically on the pre-scope baseline — environmental (broken vhost-vsock in the test runner), not a regression.Dependencies
scope_filter_enabledhook field,set_scope_enabledportal op, andigloo_in_scopegating).shell.py's gate uses the generator form introduced there. Base will retarget tomainonce shell: read guest memory via yielding portalcall API #869 merges.