Consider clobbering registers before jump to catch handler in throw stub
Categories
(Core :: JavaScript: WebAssembly, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox97 | --- | fixed |
People
(Reporter: rhunt, Assigned: rhunt)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
In the wasm throw stub we will perform a longjmp to the nearest enclosing wasm catch handler. As a security hardening measure, we should consider clobbering registers immediately before the jump [1] to mitigate possible regalloc bugs in the function we're jumping to. There could be other security issues this would help out with as well, the regalloc one just seems the most likely.
Two questions if we do this:
- Which registers? I think we could clobber all GPR's. I don't think we need to do floating point registers.
- What value to clobber with? I think zero is the safest, but maybe there's a sentinel value that could help us identify crashes with?
I don't think this would be a code bloat issue as this is once per-module. I don't think we would be concerned with performance either, as we're intentionally not concerned with performance of the exceptional path.
Comment 1•3 years ago
|
||
In principle all GPRs except nonvolatile registers (tls, heapreg, sp, psp). I think clobbering the FPRs would be a good thing too; if we're concerned about data leakage, we should worry about all data. This is especially true as wasm makes it fairly easy to control / predict register content.
I think using a nonzero sentinel value would be good. A signaling NaN with a distinct payload might be good for the FPRs.
Assignee | ||
Comment 2•2 years ago
|
||
This commit changes the throw stub to clobber most registers
before jumping to the catch landing pad. The exact details of
which registers to clobber is commented in the stub.
Updated•2 years ago
|
Pushed by rhunt@eqrion.net: https://hg.mozilla.org/integration/autoland/rev/30a14fc76d6f wasm: Clobber registers before jump in throw stub. r=lth
Comment 4•2 years ago
|
||
Backed out for causing SM bustages on Assembler-arm.cpp
Backout link: https://hg.mozilla.org/integration/autoland/rev/60101e3d02df7032545c71f18df2cf7942d64bce
Failure log: https://treeherder.mozilla.org/logviewer?job_id=362697406&repo=autoland
Failure line: Assertion failure: dest.isDouble(), at /builds/worker/checkouts/gecko/js/src/jit/arm/Assembler-arm.cpp:1587
Assignee | ||
Comment 5•2 years ago
|
||
Arm32 needs special handling due to its unique FPU registers.
Pushed by rhunt@eqrion.net: https://hg.mozilla.org/integration/autoland/rev/522bac8e0bb9 wasm: Clobber registers before jump in throw stub. r=lth
Comment 7•2 years ago
|
||
bugherder |
Description
•