Closed Bug 2010315 Opened 10 months ago Closed 6 months ago

Don't generate wasm traps if load/store is outside reserved guard regions

Categories

(Core :: JavaScript: WebAssembly, task, P3)

task

Tracking

()

RESOLVED FIXED
152 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr140 --- wontfix
firefox150 --- wontfix
firefox151 --- wontfix
firefox152 --- fixed

People

(Reporter: rhunt, Assigned: rhunt)

References

Details

(Keywords: perf-alert, sec-other, Whiteboard: [adv-main152-])

Attachments

(1 external file)

The wasm signal handler only checks if a faulting instruction is:

  1. in wasm code
  2. at an intentionally marked 'TrapSite' PC

So if we have a wasm load/store that somehow accesses memory outside of the reserved wasm memory and hits an access violation, we convert that into wasm trap. This obscures real bugs and prevents fuzzers from finding them.

We should see if we can use the effective address to filter out bad loads. One difficult part of this is that we need to somehow find the valid regions of wasm memory. I think we could use the wasm::Instance and iterate over the wasm memory objects. Wasm-GC would be harder, so probably won't start with that.

The other difficult part is getting the effective address. We have 3 cases:

  1. Win32 VectoredExceptionHandling - ExceptionInfo->ExceptionRecord->ExceptionInformation[1] holds the effective address
  2. Mach Exception Handlers - [1] request.body.code[1]
  3. POSIX signals - si_addr holds the address [2]

[1] https://searchfox.org/firefox-main/rev/5917a9f2af3294b27a325371c5c499e7dd9554fd/js/src/wasm/WasmSignalHandlers.cpp#617
[2] https://man7.org/linux/man-pages/man2/sigaction.2.html

See Also: → 2010050
Attached file (secure) —

The patch fixes this and also bug 1818639. I need to test it more, and on other platforms before requesting review.

See Also: → 1818639
Assignee: nobody → rhunt
Status: NEW → ASSIGNED
Group: javascript-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch

(In reply to Sebastian Hengst [:aryx] (needinfo me if it's about an intermittent or backout) from comment #4)

https://hg.mozilla.org/mozilla-central/rev/07dc477b4b48

Perfherder has detected a browsertime performance change from push 07dc477b4b4841f21501709ee46a3194716ec9e4.

No action is required from the author; this comment is provided for informational purposes only.

Improvement Test Platform Options Absolute values [old vs new] Performance Profiles
5% jetstream3 cdjs-Average (doc) macosx1500-aarch64-shippable fission webrender 27.38 ms -> 25.94 ms

Need Help or Information?

If you have any questions, please reach out to fbilt@mozilla.com. Alternatively, you can find help on Slack by joining #perf-help, and on Matrix you can find help by joining #perftest.

Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.

Keywords: perf-alert
QA Whiteboard: [sec] [qa-triage-done-c153/b152]
Whiteboard: [adv-main-152-]
Whiteboard: [adv-main-152-] → [adv-main152-]
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: