Commit 6670c2a
committed
More strictly check bounds in FACT trampolines
This commit is a hardening of the various in-bounds checks and such of
the FACT compiler, in particular as related to strings. The previous
implementation would check bounds in a few places but this was a bit
ad-hoc and not uniformly done. There's no known issue with the prior
checks, but given the sensitive nature of these checks I feel it's best
to make this a bit more rigorous.
Specifically the `malloc` helpers, and a newly added `realloc` helper,
will internally verify not only alignment but additionally the size of
the allocation itself. All manual invocations of `realloc` are switched
over to this helper. Additionally all conversion of a guest pointer to a
more structured value now additionally goes through helpers which
performs these same checks to ensure that everything is in-bounds.
The net result is that this should have no behavior change from before.
A suite of tests are added for behavior around large strings,
specifically exercising the maximum allowable size of strings. This
uncovered a few minor issues in transcoding where spec-wise Wasmtime
previously transcoded too many bytes before performing a
growing `realloc`.
Finally a few refactorings were done in FACT to handle some helpers
going away, notably around translating the `map<K, V>` type, which
cleans up the internals as well.1 parent f2bde1e commit 6670c2a
6 files changed
Lines changed: 798 additions & 387 deletions
File tree
- crates
- cranelift/src/compiler
- environ/src
- fact
- wasmtime/src/runtime/vm/component
- tests/misc_testsuite/component-model
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1860 | 1860 | | |
1861 | 1861 | | |
1862 | 1862 | | |
| 1863 | + | |
| 1864 | + | |
1863 | 1865 | | |
1864 | 1866 | | |
1865 | 1867 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
215 | | - | |
| 214 | + | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| |||
0 commit comments