WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
201006
Wasm's AirIRGenerator::addLocal() and B3IRGenerator::addLocal() are doing unnecessary overflow checks.
https://bugs.webkit.org/show_bug.cgi?id=201006
Summary
Wasm's AirIRGenerator::addLocal() and B3IRGenerator::addLocal() are doing unn...
Mark Lam
Reported
2019-08-21 16:12:59 PDT
<
rdar://problem/52053991
>
Attachments
proposed patch.
(1.68 KB, patch)
2019-08-21 16:18 PDT
,
Mark Lam
mark.lam
: review-
Details
Formatted Diff
Diff
proposed patch.
(4.33 KB, patch)
2019-08-28 14:13 PDT
,
Mark Lam
ysuzuki
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Mark Lam
Comment 1
2019-08-21 16:18:13 PDT
Created
attachment 376946
[details]
proposed patch.
Keith Miller
Comment 2
2019-08-21 16:21:02 PDT
Comment on
attachment 376946
[details]
proposed patch. r=me.
Mark Lam
Comment 3
2019-08-21 17:23:30 PDT
Comment on
attachment 376946
[details]
proposed patch. Actually, this change is not needed. Details to follow.
Mark Lam
Comment 4
2019-08-21 17:30:30 PDT
Validate::addLocal() can never overflow because: 1. It is only called from m_context.addArguments() and FunctionParser<Context>::parse(). 2. m_context.addArguments() will add the number of arguments in the signature passed to it. In SectionParser::parseType(), we already ensure that the number of arguments do not exceed maxFunctionParams, which is 1000 (see WasmLimits.h). 3. FunctionParser<Context>::parse() will also call addLocal() to add numberOfLocals for each local group. numberOfLocals is capped to maxFunctionLocals, and the number of local groups is currently capped to maxFunctionLocals also. maxFunctionLocals is 50000 (see WasmLimits.h). As a result, the max possible number of locals added = 1000 + (50000 * 50000) = 2500001000 = 0x9502FCE8, which is less that UINT_MAX. There is no chance of an overflow here.
Mark Lam
Comment 5
2019-08-28 13:50:52 PDT
Actually, AirIRGenerator::addLocal() and B3IRGenerator::addLocal() are both doing unnecessary overflow checks. We already ensured that it is not possible to overflow in Wasm::FunctionParser's parse(). It is unnecessary and misleading to do those overflow checks in AirIRGenerator and B3IRGenerator. The only check that is necessary is that m_locals.tryReserveCapacity() is successful, otherwise, we have an out of memory situation. I'll use this bug to change these unnecessary checks to assertions instead.
Mark Lam
Comment 6
2019-08-28 14:13:37 PDT
Created
attachment 377483
[details]
proposed patch.
Yusuke Suzuki
Comment 7
2019-08-28 14:18:11 PDT
Comment on
attachment 377483
[details]
proposed patch. r=me. These checks are redundant to WasmFunctionParser and the responsibility of this check should belong to WasmFunctionParser. Not to each client.
Mark Lam
Comment 8
2019-08-28 14:25:43 PDT
Thanks for the review. Landed in
r249221
: <
http://trac.webkit.org/r249221
>.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug