Closed Bug 809021 Opened 9 years ago Closed 9 years ago

IonMonkey: Opt-only Crash [@ GetValueType] or Crash [@ js::ion::ReflowTypeInfo]

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
critical

Tracking

()

RESOLVED FIXED
mozilla19
Tracking Status
firefox16 --- unaffected
firefox17 --- unaffected
firefox18 + fixed
firefox19 + fixed
firefox-esr10 --- unaffected
firefox-esr17 --- unaffected

People

(Reporter: decoder, Assigned: jandem)

References

Details

(6 keywords, Whiteboard: [jsbugmon:ignore][adv-main18-])

Crash Data

Attachments

(3 files)

Attached file Testcase for shell
The attached testcase crashes on mozilla-central revision f9c2c266e7aa (run with --ion-eager).
This crashes only in opt-builds:

==65276== Invalid read of size 8
==65276==    at 0x6E0AB1: js::ion::ReflowTypeInfo(unsigned int) (Barrier.h:171)
==65276==    by 0x402670E: ???
==65276==    by 0x6E6E3E: js::ion::FastInvoke(JSContext*, JS::Handle<JSFunction*>, js::CallArgsList&) (Ion.cpp:1559)
==65276==    by 0x430511: array_some(JSContext*, unsigned int, JS::Value*) (jsinterpinlines.h:1041)
==65276==    by 0x4028146: ???
==65276==    by 0x6E6E3E: js::ion::FastInvoke(JSContext*, JS::Handle<JSFunction*>, js::CallArgsList&) (Ion.cpp:1559)
==65276==    by 0x430511: array_some(JSContext*, unsigned int, JS::Value*) (jsinterpinlines.h:1041)
==65276==    by 0x4028146: ???
==65276==    by 0x6E6E3E: js::ion::FastInvoke(JSContext*, JS::Handle<JSFunction*>, js::CallArgsList&) (Ion.cpp:1559)
==65276==    by 0x430511: array_some(JSContext*, unsigned int, JS::Value*) (jsinterpinlines.h:1041)
==65276==    by 0x4028146: ???
==65276==    by 0x6E6E3E: js::ion::FastInvoke(JSContext*, JS::Handle<JSFunction*>, js::CallArgsList&) (Ion.cpp:1559)
==65276==  Address 0x800000000007 is not stack'd, malloc'd or (recently) free'd
==65276== 
==65276== 
==65276== Process terminating with default action of signal 11 (SIGSEGV)
==65276==  General Protection Fault


However in debug builds, it is also visible in Valgrind:

==63660== Conditional jump or move depends on uninitialised value(s)
==63660==    at 0x4679EF: js::types::GetValueType(JSContext*, JS::Value const&) (jsinferinlines.h:191)
==63660==    by 0x505FED: js::types::TypeScript::SetArgument(JSContext*, JS::Handle<JSScript*>, unsigned int, JS::Value const&) (jsinferinlines.h:1022)
==63660==    by 0x8779AB: ReflowArgTypes(JSContext*) (Bailouts.cpp:464)
==63660==    by 0x877A54: js::ion::ReflowTypeInfo(unsigned int) (Bailouts.cpp:477)
==63660==    by 0x402683E: ???
==63660==    by 0x8846FC: js::ion::FastInvoke(JSContext*, JS::Handle<JSFunction*>, js::CallArgsList&) (Ion.cpp:1559)
==63660==    by 0x46B8C2: js::FastInvokeGuard::invoke(JSContext*) (jsinterpinlines.h:1041)
==63660==    by 0x47DA8D: bool array_readonlyCommon<ArraySomeBehavior>(JSContext*, JS::CallArgs&) (jsarray.cpp:3123)
==63660==    by 0x4780FA: array_some(JSContext*, unsigned int, JS::Value*) (jsarray.cpp:3152)
==63660==    by 0x4027FB1: ???
==63660==    by 0x883FA5: EnterIon(JSContext*, js::StackFrame*, void*) (Ion.cpp:1426)
==63660==    by 0x884286: js::ion::Cannon(JSContext*, js::StackFrame*) (Ion.cpp:1464)
==63660== 
==63660== Conditional jump or move depends on uninitialised value(s)
==63660==    at 0x40281E0: ???
==63660==    by 0x8846FC: js::ion::FastInvoke(JSContext*, JS::Handle<JSFunction*>, js::CallArgsList&) (Ion.cpp:1559)
==63660==    by 0x46B8C2: js::FastInvokeGuard::invoke(JSContext*) (jsinterpinlines.h:1041)
==63660==    by 0x47DA8D: bool array_readonlyCommon<ArraySomeBehavior>(JSContext*, JS::CallArgs&) (jsarray.cpp:3123)
==63660==    by 0x4780FA: array_some(JSContext*, unsigned int, JS::Value*) (jsarray.cpp:3152)
==63660==    by 0x4028376: ???
==63660==    by 0x883FA5: EnterIon(JSContext*, js::StackFrame*, void*) (Ion.cpp:1426)
==63660==    by 0x884286: js::ion::Cannon(JSContext*, js::StackFrame*) (Ion.cpp:1464)
==63660==    by 0x539BBF: js::RunScript(JSContext*, JS::Handle<JSScript*>, js::StackFrame*) (jsinterp.cpp:301)
==63660==    by 0x53A2AB: js::InvokeKernel(JSContext*, JS::CallArgs, js::MaybeConstruct) (jsinterp.cpp:379)
==63660==    by 0x4664FB: js::Invoke(JSContext*, js::InvokeArgsGuard&, js::MaybeConstruct) (jsinterp.h:109)
==63660==    by 0x46B989: js::FastInvokeGuard::invoke(JSContext*) (jsinterpinlines.h:1059)


Marking s-s and sec-critical based on that info, as the pointer could be controllable if it comes from uninitialized memory. Feel free to downgrade if appropriate.
Blocks: IonFuzz
Crash Signature: [@ GetValueType] or Crash [@ js::ion::ReflowTypeInfo] → [@ GetValueType] [@ js::ion::ReflowTypeInfo]
Summary: Opt-only Crash [@ GetValueType] or Crash [@ js::ion::ReflowTypeInfo] → IonMonkey: Opt-only Crash [@ GetValueType] or Crash [@ js::ion::ReflowTypeInfo]
Whiteboard: [jsbugmon:ignore]
The following test is much simpler and shows very similar behavior (but with a null-crash instead of the above dangerous one):

eval('(function () { unescape("foo"); [1, 2, 3].sort(function (i,re,s) {}); })();');
Jan, does this look related to the FastInvoke patch?
Assignee: general → jdemooij
Status: NEW → ASSIGNED
Attached patch PatchSplinter Review
The problem is that there are more actual than formal arguments and we could read bogus values. The patch just rejects this case, real-world code often has nformals < nactuals with array.map etc, but nformals > nactuals should be rare.
Attachment #680999 - Flags: review?(dvander)
(In reply to Jan de Mooij [:jandem] from comment #4)
> The problem is that there are more actual than formal arguments

Er, more formal than actual arguments.
Attachment #680999 - Flags: review?(dvander) → review+
Comment on attachment 680999 [details] [diff] [review]
Patch

[Security approval request comment]
How easily can the security issue be deduced from the patch?

Quite easily.

Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?

Comments and tests, but even if I remove them the problem is pretty obvious from the code itself.

Which older supported branches are affected by this flaw?

Firefox 18.

If not all supported branches, which bug introduced the flaw?

IonMonkey.

Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?

Patch should apply to Firefox 18.

How likely is this patch to cause regressions; how much testing does it need?

Unlikely, doesn't need much testing.
Attachment #680999 - Flags: sec-approval?
Comment on attachment 680999 [details] [diff] [review]
Patch

Sec-approval+. Please prepare a patch for 18 as well.
Attachment #680999 - Flags: sec-approval? → sec-approval+
Attachment #680999 - Attachment description: Pach → Patch
Attached patch Patch for 18Splinter Review
Patch for Firefox 18. No real conflicts, somebody added AssertCanGC(); on m-c and that made hg complain when importing the patch.

Will ask for approval when the fix is on m-c.
Attachment #681412 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/24b745c02ce7
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
Comment on attachment 681412 [details] [diff] [review]
Patch for 18

[Approval Request Comment]
Bug caused by (feature/regressing bug #): IonMonkey
User impact if declined: Critical security bug, crashes, correctness issues.
Testing completed (on m-c, etc.): On m-c for a few days
Risk to taking this patch (and alternatives if risky): Low
String or UUID changes made by this patch: None
Attachment #681412 - Flags: approval-mozilla-aurora?
Comment on attachment 681412 [details] [diff] [review]
Patch for 18

[Triage Comment]
Low risk sec-critical regression fix. Please land before Monday morning PT to make it in before the merge.
Attachment #681412 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Duplicate of this bug: 811563
Whiteboard: [jsbugmon:ignore] → [jsbugmon:ignore][adv-main18-]
Group: core-security
You need to log in before you can comment on or make changes to this bug.