Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[mini] Fix the bounds check in GET_BBLOCK
If the target IP is out of bounds, but `cfg->cil_offset_to_bb` has
some non-zero data before or after it, then `tblock` will be some
non-NULL pointer that we will treat as a good basic block.

Related to #73474 (but doesn't
fix the underlying issue there - it will just make the whole
offending method throw a BadImageFormatException when it's called)

This may have some performance overhead for the mono JIT.
  • Loading branch information
lambdageek committed Aug 5, 2022
commit ac59644428ffa91d28526418cf29b5248cd2f73f
2 changes: 1 addition & 1 deletion src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,9 @@ mini_set_inline_failure (MonoCompile *cfg, const char *msg)
} while (0)

#define GET_BBLOCK(cfg,tblock,ip) do { \
if ((ip) >= end || (ip) < header->code) { UNVERIFIED; } \
(tblock) = cfg->cil_offset_to_bb [(ip) - cfg->cil_start]; \
if (!(tblock)) { \
if ((ip) >= end || (ip) < header->code) UNVERIFIED; \
NEW_BBLOCK (cfg, (tblock)); \
(tblock)->cil_code = (ip); \
ADD_BBLOCK (cfg, (tblock)); \
Expand Down