未验证 提交 7c060202 编写于 作者: A Aleksey Kliger (λgeek) 提交者: GitHub

[mini] Fix the bounds check in GET_BBLOCK (#73493)

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 https://github.com/dotnet/runtime/issues/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.
上级 d8dbd956
......@@ -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)); \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册