Skip to content

[v8] Add Maglev type-confusion and differential fuzzing - #562

Closed
srinivasreddy wants to merge 2 commits into
googleprojectzero:mainfrom
srinivasreddy:maglev-type-confusion-differential-fuzzing
Closed

srinivasreddy wants to merge 2 commits into
googleprojectzero:mainfrom
srinivasreddy:maglev-type-confusion-differential-fuzzing

Conversation

@srinivasreddy

Copy link
Copy Markdown

Summary

Adds a Maglev-focused program template and an output-based differential oracle.

  • MaglevTypeConfusionFuzzer: elements-kind, map/field-representation, typed-array, binary feedback, call/inlining, and loop/Phi assumption invalidation.
  • C1.1-shaped variants: value-equal HeapNumber/Smi checks, mixed-representation Phis, backedge-only representation changes, and inlined Smi proofs, with explicit gc() observation and printed digests.
  • Output-based differential fuzzing: Maglev vs. --no-maglev --no-turbofan, with reference-timeout handling, plus the v8Maglev profile (determinism shim, periodic GC, focused code generators).
  • IteratorHelpersFuzzer: iterator helper chains including chunks()/windows().
  • Unit, profile, template, and live differential tests.

Testing

  • swift build and swift build -c release --product FuzzilliCli: pass
  • swift test --filter DiffExecutionTests: 6/6 pass
  • swift test --filter MaglevDifferential: live 25 program pairs, 0 false differentials
  • swift test --filter MaglevTypeConfusion: construction + live pass
  • 80 s v8Maglev CLI run: startup passed, HybridEngine reached, 0 confirmed differentials, 0 crashes

Add MaglevTypeConfusionFuzzer, targeting elements-kind, map and field-representation, typed-array, binary feedback, call/inlining and loop/Phi assumptions. Includes C1.1-shaped variants for value-equal HeapNumber/Smi checks, mixed-representation Phis, backedge-only representation changes and inlined Smi proofs, with explicit gc() observation and output digests.

Add output-based differential fuzzing (Maglev vs. --no-maglev --no-turbofan) with reference-timeout handling, plus the v8Maglev differential profile, determinism shim, periodic GC and focused code generators.

Also add IteratorHelpersFuzzer and unit/live tests for the oracle, profile, templates and differential execution.
Address review feedback: add staging flags to the Maglev template live test; age the value-equal HeapNumber target into old space before the store; feed the Phi result into a HeapObject consumer for the 486657483 shape; lengthen the backedge trigger loop and warm the callee for inlining; guard the reference runner, preserve crash outcomes, treat both-failed runs as non-differential and mark reference timeouts; extend the determinism shim with performance.now.
@srinivasreddy

Copy link
Copy Markdown
Author

Review follow-up pushed in f1a05380.

Fixed:

  • Added --future --harmony --js-staging --fuzzing to the Maglev template live test.
  • Aged the value-equal HeapNumber target into old space (gc() twice) before the store.
  • Reworked the Phi variant so the tagged Phi result feeds a HeapObject consumer (length/[0]), matching 486657483 rather than arithmetic.
  • Increased the backedge trigger loop to 20-50 iterations and made the changed backedge the final iteration.
  • Warm/optimize the inlined callee before warming the caller.
  • Guard referenceRunner, preserve crash outcomes, treat both-failed runs as non-differential, mark reference timeouts, and document that stderr is report-only.
  • Extended the determinism shim with performance.now.

Notes on three flagged items:

  • ObjectGroup.jsIteratorWindowsUndersizedEnum and OptionsBag.jsIteratorZipSettings are pre-existing base symbols, registered at JavaScriptEnvironment.swift:551 and :623 (definitions at :2380 and :5332); the patch compiles and both iterator tests pass.
  • optimized.output is JavaScriptExecutor.Result.output in LiveTests, not Execution; it compiles.
  • IteratorHelpersFuzzer is registered only in V8Profile and V8DumplingProfile, not in v8MaglevDifferentialProfile.

Tests after the fixes: DiffExecutionTests 7/7, live MaglevDifferential 25 pairs / 0 differentials, and MaglevTypeConfusion construction + live tests all pass.

@srinivasreddy

Copy link
Copy Markdown
Author

Added the end-to-end VRP workflow in 3ee6257e.

New tools and docs:

  • Tools/v8-vrp-campaign.sh: long v8 crash and v8Maglev differential campaigns, metadata/revision capture, logs, ASan campaign, resume, and an explicitly separated v8MaglevFaultInjection canary.
  • Tools/v8-vrp-triage.py: reproduces stored crashes/differentials from their recorded TARGET ARGS/ARGS/REFERENCE ARGS, checks determinism, optionally runs ASan, marks injected-fault artifacts, and writes Markdown + JSON reports.
  • Docs/V8VRPWorkflow.md: builds, campaigns, triage, false-positive handling, security assessment, and VRP reporting.

Fault-injection layer (clearly not a VRP finding):

  • Targets/V8/Patches/maglev-fault-injection.patch adds --maglev-fuzz-drop-heapobject-check, which drops HeapObjectness in ConvertTaggedPhiTo, corrupts a converted Phi input, and removes the following CheckHeapObject.
  • Dedicated MaglevPhiHeapObjectnessFaultFuzzer and v8MaglevFaultInjection profile. Against the patched d8 it produced 4 deterministic crashes in one run; triage correctly labeled all 4 as injected (0 non-injected findings).

Usage:

Tools/v8-vrp-campaign.sh --d8 <fuzzbuild/d8> --asan-d8 <asan/d8> --jobs 8 --duration 2h --out /tmp/v8-vrp
Tools/v8-vrp-triage.py /tmp/v8-vrp/storage/v8 --d8 <fuzzbuild/d8> --asan-d8 <asan/d8> --out /tmp/v8-vrp/triage-v8

Checklist for reported candidates: no --maglev-fuzz-drop-heapobject-check, deterministic on a clean build, ASan-confirmed where applicable, and security impact assessed.

@srinivasreddy

Copy link
Copy Markdown
Author

Superseded by #563, which is based on the current public fork branch and includes the VRP campaign/triage workflow plus the Maglev fault-injection layer (3ee6257e).

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