Skip to content

feat(ghidra): inspect FreeBSD amd64 installations - #7174

Open
ocochard wants to merge 5 commits into
morluto:mainfrom
ocochard:freebsd
Open

ocochard wants to merge 5 commits into
morluto:mainfrom
ocochard:freebsd

Conversation

@ocochard

@ocochard ocochard commented Oct 25, 2026 •

Copy link
Copy Markdown

Current revision

49d7b18548 limits the current change to read-only FreeBSD/amd64 Ghidra package inspection. REA identifies the packaged ELF decompiler and returns unsupported_host before probing Java. The shared ownership and sampling code matches main.

The earlier prototype's shared preflight blocked unrelated workers, while a lower-level signaling path could still treat a one-second lstart value as generation identity. The original commits and prototype remain in the branch history. FreeBSD execution still needs a scope decision, native generation and run-token evidence, and real-host cancellation and cleanup verification.

On macOS/arm64, 923 focused tests passed with two skips and npm run check:fast passed. The regression also showed that removing the platform guard attempted the JVM probe. The original submission below records @ocochard’s reproduction and native smoke test on the earlier stacked branch.


Summary

Let the Ghidra provider run on FreeBSD/amd64 hosts. Today rea doctor reports Ghidra as unavailable on FreeBSD
even with a working Ghidra installation, because REA rejects the platform, cannot find the FreeBSD native decomp
iler, and cannot track the processes it launches (the Java probe fails), since process identities are read only
from Linux procfs or the Darwin reader.

Problem and expected behavior

On FreeBSD 16.0-CURRENT amd64 with the ghidra package (GHIDRA_INSTALL_DIR=/usr/local/share/ghidra), rea doc tor reports for Ghidra:

platform,false,unsupported_host,freebsd
architecture,false,unsupported_host,x64
native_decompiler,false,executable_missing,Matching native decompiler for freebsd/x64 was not found
java,false,runtime_unavailable,"java: Process ownership baseline is unavailable on this host"

Underlying causes:

  1. NATIVE_PLATFORMS / NATIVE_TOOL_FORMATS have no freebsd entry, and the JVM os.name check has no FreeBS
    D case. The FreeBSD package ships the decompiler at Ghidra/Features/Decompiler/build/os/freebsd_x86_64/decompil e, a path REA already searches once the platform is mapped.
  2. ps -axo pid=,ppid=,... is procps syntax. BSD ps treats everything after the first = as the column heade
    r, so the process listing returns only PIDs. FreeBSD also has no sess keyword (sid is the session id).
  3. processIdentities / captureBaseline exist only for Linux and Darwin, so owned-process launches that require a baseline (the Ghidra Java probe) fail.

Expected: with a supported Ghidra release and JDK, Ghidra is available: true on FreeBSD/amd64, and owned processes are tracked and cleaned up as on Linux.

Change and scope

  • src/ghidra/GhidraInstallation.ts: map freebsd/x64 to freebsd_x86_64, expect ELF native tools, accept os.name=FreeBSD.
  • src/process/ProcessOwnershipObservation.ts, src/process/capture/ProcessSampling.ts: pass one -o per ps column (valid for both procps and BSD ps), use sid= instead of sess= on FreeBSD.
  • src/process/ProcessOwnershipObservation.ts: add a FreeBSD identity reader based on one ps -o pid= -o ppid= -o pgid= -o uid= -o stat= -o lstart= -p <pids> snapshot. It gives a freebsd-lstart: start identity, the relation (parent, process group), effective UID and lifecycle (Z means zombie, E means exiting). A PID missing from the snapshot is reported absent. FreeBSD ps exits 1 without output when none of the requested PIDs exist, and that case is also treated as all absent. Enable captureBaseline / processIdentities for FreeBSD.

Not included: setup/installer support for FreeBSD, other providers (JADX, NativeAOT and PSP remain Linux-only), arm64 FreeBSD. Accepting newer Ghidra 12.x minors is a separate PR.

Known limitation: lstart has one-second resolution, so the start identity cannot tell apart two processes that get the same PID within the same second. On FreeBSD that needs the PID space to wrap within one second, which is unlikely, but it is weaker than Linux's clock-tick start time. A sysctl kern.proc.pid reader (microsecond ki_start) would be stronger but needs native code.

Follow the contribution scope. Scope decision pending: this adds a new host platform.

Contract and boundary impact

  • Semantic owner and earliest changed stage: createSystemProcessOwnershipHost (process listing and identities) and Ghidra installation inspection. Linux and Darwin paths unchanged apart from the ps argument form.
  • Contribution scope fit and linked maintainer decision: pending (new host platform).
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: adds FreeBSD/amd64 host support for the Ghidra provider.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): process identity and cleanup revalidation on FreeBSD now use ps snapshots, see the limitation above.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: none yet. The FreeBSD identity reader has no unit test; that is a gap to close before review.
  • Base reproduction or other evidence: the rea doctor output above, on unpatched main.
  • User-visible CLI/MCP output: after the change, rea doctor reports Ghidra as available: true with native_decompiler,true,null,".../build/os/freebsd_x86_64/decompile reports elf x86_64, which matches freebsd/x64", and rea decompile <elf> square --provider ghidra returns int square(int param_1) { return param_1 * param_1; }. Afterwards no Ghidra or decompiler processes are left running.
  • Remaining proof gaps: no FreeBSD CI; unit tests for the FreeBSD reader; Ghidra 12.1.x on FreeBSD not tested (the host has Ghidra 12.2, see below).

Validation performed

Host: FreeBSD 16.0-CURRENT amd64, Node v24.21.0 (below engines, dependencies installed with --engine-strict=false), OpenJDK 25.0.4, Ghidra 12.2 (FreeBSD package).

  • node scripts/run-typescript.mjs --noEmit on this branch: passed.
  • npx vitest run src/ghidra/GhidraInstallation.test.ts on this branch: 104 passed, 6 failed. The same 6 (keeps JDK registration identity for ...) fail on unpatched main on this host.
  • vitest on 71 files covering process ownership, process capture and Ghidra installation, run on this branch plus the Ghidra 12.x PR: 44 failed / 795 passed / 45 skipped, against 90 failed / 749 passed on unpatched main on the same FreeBSD host. No test fails only with the change. These failures come from the FreeBSD host and are unrelated to this change.
  • Real Ghidra: rea doctor and rea decompile as above. These need Ghidra 12.2 accepted, so they ran with the Ghidra 12.x PR applied.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Ghidra 12.2 on FreeBSD 16.0-CURRENT amd64; Linux and macOS not re-run here.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: process identity on FreeBSD depends on ps output, with a one-second start-time resolution (see limitation).

Author readiness

Human owner: @ocochard

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Map freebsd/x64 to Ghidra's freebsd_x86_64 native directory (found
under build/os in FreeBSD packages), expect ELF native tools, and
accept a JVM reporting os.name=FreeBSD.
BSD ps treats everything after the first '=' in -o as the column
header, so pass one -o per column. FreeBSD has no 'sess' keyword; use
'sid' there.

Without procfs, read process identities on FreeBSD from one ps snapshot:
lstart as the start identity, plus parent, process group, effective UID
and zombie/exiting state. FreeBSD ps exits 1 without output when none of
the requested PIDs exists; report those PIDs as absent. This lets
owned-process baselines and cleanup revalidation work, which the Ghidra
provider requires to launch Java.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T16:13:09.472826Z 49d7b18 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Low impact] The narrowed inspection-only change appears safe to merge; it does not enable FreeBSD execution.

Summary

Recognizes FreeBSD’s native decompiler path and ELF header without enabling Ghidra execution.

  • Ghidra inspection recognizes FreeBSD tools but still blocks launches.

Reviews (3) · Last reviewed commit: "fix(ghidra): keep FreeBSD inspection out..." · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74d78d6f72

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/ghidra/GhidraInstallation.ts Resolved
Comment thread src/ghidra/GhidraInstallation.ts Resolved
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: The PR adds no tests, so I ran 21 existing Linux test files for the changed code on Node 22.23.4, 24.22.1 and 26.12.1. All passed on each version, with 1 test skipped. I did not run FreeBSD, and the CI run on this head has no test jobs.

Check on 74d78d6 Node 22.23.4 Node 24.22.1 Node 26.12.1
Test files pass, 21 of 21 pass, 21 of 21 pass, 21 of 21
Tests pass, 417 passed, 1 skipped (418) pass, 417 passed, 1 skipped (418) pass, 417 passed, 1 skipped (418)
  • The PR changes 3 files against the merge base: src/ghidra/GhidraInstallation.ts, src/process/ProcessOwnershipObservation.ts and src/process/capture/ProcessSampling.ts. None are test files. So I picked 21 existing test files for these source files. They are the ProcessOwnership and ProcessSampling tests and src/ghidra/GhidraInstallation.test.ts. I added tests/boundary/filesystem/recordedCrashTraceClassifier.test.ts, which mentions -axo.
  • Workflow runs on the head: CI is completed/action_required, PR title is completed/action_required, and PR readiness is completed/failure.
  • Check run Validate author declaration is failure, and Greptile Review is success. Commit status PR readiness is failure.
  • The check runs of the CI run show no Source tests, Portable tests or Test shard jobs.
  • The head is 1238 commits behind main 88cf498. GitHub says the PR is mergeable; its merge state is blocked.

Not run

  • A FreeBSD host, where the new ps path actually runs.
  • A run with a ps row the new FreeBSD regex doesn't match, such as an empty lstart field.
  • A merge with current main, 88cf498.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 74d78d6 / 1173c0a (merge base with main)
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/process/ProcessOwnership.baselineAbsence.test.ts src/process/ProcessOwnership.exitScope.test.ts src/process/ProcessOwnership.exiting.test.ts src/process/ProcessOwnership.finalSweep.test.ts src/process/ProcessOwnership.identity.test.ts src/process/ProcessOwnership.lineage.test.ts src/process/ProcessOwnership.nativeExit.test.ts src/process/ProcessOwnership.observation.test.ts src/process/ProcessOwnership.part2.test.ts src/process/ProcessOwnership.part3.test.ts src/process/ProcessOwnership.procIdentity.test.ts src/process/ProcessOwnership.runId.test.ts src/process/ProcessOwnership.sweepExit.test.ts src/process/ProcessOwnership.test.ts src/process/ProcessOwnership.tokenAvailability.test.ts src/process/ProcessOwnership.validation.test.ts src/process/ProcessOwnershipFacts.test.ts src/process/capture/ProcessCaptureOwnershipEvidence.test.ts src/process/capture/ProcessSampling.procReadCoverage.test.ts src/ghidra/GhidraInstallation.test.ts tests/boundary/filesystem/recordedCrashTraceClassifier.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto

morluto commented Nov 21, 2026

Copy link
Copy Markdown
Owner

I've opened #13140 as an attributed draft continuation. It preserves @ocochard's original commits, reconciles current main, and carries the process-observation fixes and controlled tests. The draft records the remaining FreeBSD scope decision, native identity and token evidence, and real-host cleanup validation.

On this original PR, PR readiness fails because the three author declarations are still unchecked. Those declarations belong to the human owner. The follow-up is a draft so that work and review can continue while the scope and verification questions are open.

Thanks @ocochard for the FreeBSD reproduction, initial implementation, and real Ghidra smoke test.

@morluto

morluto commented Nov 21, 2026

Copy link
Copy Markdown
Owner

@ocochard Thanks for the FreeBSD reproduction, the original implementation, and the Ghidra smoke test. We’re continuing here on your PR. I fast-forwarded the branch to 8891f31e74, preserving both of your commits and bringing in current main. The follow-up is in dc1949465e, and the duplicate draft #13140 is closed.

The old reader treated any row it could not parse as proof of exit. The follow-up parses each row independently and keeps malformed or invisible PIDs unresolved. We verified the regression by restoring the old classification and seeing both tests fail. The focused macOS run passed 552 tests with two skips, and npm run check:fast passed.

FreeBSD owned launches are gated on this head. FreeBSD can hide a live PID from ps, lstart has only second precision, and ps eww mixes argv and environment into one field. We need a generation-aware source for identity and a separate source for the run token before enabling cleanup. FreeBSD process visibility · procstat environment source

Could you review the changes and let us know whether your FreeBSD/amd64 host is available for the next round of native validation? The original readiness check requires the three declarations from the human owner. Please complete them when you consider the PR ready for review.

@morluto morluto left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 49d7b18548. The diff adds read-only Ghidra package inspection on FreeBSD/amd64. It identifies the packaged x86-64 ELF decompiler, reports unsupported_host, and skips the Java probe. The regression fails if that probe runs. Shared process ownership and sampling match main.

The title still says “support FreeBSD hosts,” which implies execution. If this revision is intended to ship on its own, feat(ghidra): inspect FreeBSD amd64 installations describes what users get. If the goal remains executable support, the remaining review is the maintainer scope decision and real FreeBSD evidence for generation identity, run-token provenance, cancellation, and cleanup retry.

Local validation on macOS/arm64 passed check:fast and 923 focused tests with two skips. The FreeBSD boundary was exercised with a fixture.

@morluto morluto changed the title feat(process): support FreeBSD hosts feat(ghidra): inspect FreeBSD amd64 installations Nov 21, 2026
@morluto morluto added area: setup Setup, packaging, upgrade, install, Doctor, and client registration enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra labels Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants