Closed
Bug 710688
Opened 14 years ago
Closed 14 years ago
ASan reports heap-use-after-free in JS::Value::isMarkable
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 754146
mozilla12
People
(Reporter: decoder, Unassigned)
Details
(Keywords: sec-other, testcase, Whiteboard: js-triage-needed, [asan] [sg:dupe 754146])
Attachments
(3 files)
The attached test triggers a memory error report in ASan (tested using mozilla-central revision efab5016434f (options -m -n)).
The test is very fragile and might be hard to debug without a build to test. Let me know if you need such a build or access to a machine which has one. I will also attach the address sanitizer log, as it's a bit too long to paste here.
Marking S-s until triaged due to possible memory safety problem.
| Reporter | ||
Comment 1•14 years ago
|
||
Comment 2•14 years ago
|
||
I see a HeapReverser in there, so this may not affect the browser.
| Reporter | ||
Comment 3•14 years ago
|
||
Yea this could be a bug in findReferences itself, or a bug exposed by findReferences. If it's in findReferences, then the browser would be unaffected. Maybe jimb can answer that question. I do have ASan shell builds for Linux for download if they are needed.
Comment 4•14 years ago
|
||
The young end of the stacktrace looks like this:
=================================================================
==31191== ERROR: AddressSanitizer heap-use-after-free on address 0x7f0b2b0c1bb0 at pc 0x4dd145 bp 0x7fffc6b10130 sp 0x7fffc6b10128
READ of size 1 at 0x7f0b2b0c1bb0 thread T0
#0 0x4dd145 in JS::Value::isMarkable() const js/src/debug64asan/../../jsapi.h:467
#1 0xb1f8c2 in js::gc::MarkValueRaw(JSTracer*, JS::Value const&) js/src/jsgcmark.cpp:487
#2 0xb249d0 in js::gc::MarkRootRange(JSTracer*, JS::Value const*, JS::Value const*, char const*) js/src/jsgcmark.cpp:646
#3 0xb24db8 in js::gc::MarkRootRange(JSTracer*, unsigned long, JS::Value const*, char const*) js/src/jsgcmark.cpp:656
#4 0xa9a9eb in js::AutoGCRooter::trace(JSTracer*) js/src/jsgc.cpp:1997
#5 0xa6d8a7 in js::AutoGCRooter::traceAll(JSTracer*) js/src/jsgc.cpp:2002
#6 0xa6ddf7 in js::MarkContext(JSTracer*, JSContext*) js/src/jsgc.cpp:2022
#7 0xa6eaca in js::MarkRuntime(JSTracer*) js/src/jsgc.cpp:2059
#8 0xa74d1c in js::TraceRuntime(JSTracer*) js/src/jsgc.cpp:3044
#9 0x5f4933 in JS_TraceRuntime js/src/jsapi.cpp:2316
#10 0x50c8f5 in HeapReverser::reverseHeap() js/src/shell/jsheaptools.cpp:308
#11 0x513ab8 in FindReferences(JSContext*, unsigned int, JS::Value*) js/src/shell/jsheaptools.cpp:573
#12 0xd75d5d in js::CallJSNative(JSContext*, int (*)(JSContext*, unsigned int, JS::Value*), js::CallArgs const&) js/src/debug64asan/../jscntxtinlines.h:311
#13 0xd4229c in js::InvokeKernel(JSContext*, js::CallArgs, js::MaybeConstruct) js/src/jsinterp.cpp:625
So it's the JS_TraceRuntime helpers that are touching the freed memory, not findReferences' implementation. Perhaps findReferences has munged something, or perhaps the graph is corrupt.
Comment 5•14 years ago
|
||
Christian, could you run the same test, but with the call to findReferences that we crash on replaced by a GC? If that trips the error too, then we know it's not because of findReferences. If it doesn't then we probably don't know much, because the test case is fragile.
Otherwise, I think we'd need access to a machine with ASan builds to try to debug.
| Reporter | ||
Comment 6•14 years ago
|
||
Replacing findReferences doesn't work (but that is not surprising because the code is using the result of findReferences).
I can easily provide access to the machine where someone can look at this. I can also try to reproduce this on tip with a more recent (public) asan build. The test itself is not really stable so different build options influence it :(
Comment 7•14 years ago
|
||
(In reply to Christian Holler (:decoder) from comment #6)
> I can easily provide access to the machine where someone can look at this. I
> can also try to reproduce this on tip with a more recent (public) asan
> build. The test itself is not really stable so different build options
> influence it :(
I'll send you an SSH public key via IRC.
| Reporter | ||
Updated•14 years ago
|
Whiteboard: js-triage-needed → js-triage-needed, [asan]
| Reporter | ||
Comment 8•14 years ago
|
||
I managed to find a single-file testcase that can be reproduced using the jsshell x86-64 linux builds available at http://people.mozilla.org/~choller/firefox/asan/20120110-01d69766026d/
Maybe this will help to reproduce and debug this on your side. If not, we can still go for remote debugging.
Updated•14 years ago
|
Assignee: general → jimb
| Reporter | ||
Comment 9•14 years ago
|
||
(In reply to Jim Blandy :jimb from comment #7)
> I'll send you an SSH public key via IRC.
I just checked again and it seems I haven't received any. Just drop me an email and I'll let you know the login details on IRC :) I have reproduced this now even easier on mozilla-release without any flags.
Updated•14 years ago
|
Assignee: jimb → blackconnect
Component: JavaScript Engine → Java-Implemented Plugins
OS: Linux → Mac OS X
QA Contact: general → blackconnect
Target Milestone: --- → mozilla12
Version: Trunk → 14 Branch
Updated•14 years ago
|
Assignee: blackconnect → general
Component: Java-Implemented Plugins → JavaScript Engine
OS: Mac OS X → Linux
QA Contact: blackconnect → general
Version: 14 Branch → Trunk
Updated•14 years ago
|
Assignee: general → jimb
Comment 10•14 years ago
|
||
(In reply to Christian Holler (:decoder) from comment #9)
> (In reply to Jim Blandy :jimb from comment #7)
> > I'll send you an SSH public key via IRC.
>
> I just checked again and it seems I haven't received any. Just drop me an
> email and I'll let you know the login details on IRC :) I have reproduced
> this now even easier on mozilla-release without any flags.
Jim's in London this week for the devtools meetup, so he most likely won't be ready to send a key before next week.
| Reporter | ||
Comment 11•14 years ago
|
||
I already received the key, Jim got access and already inspected the issue. One problem is that ASan builds even seem to get optimized/loose debug information with -O0, which seems to be an LLVM/Clang bug. I'm not sure if what he found so far is sufficient to resolve the problem.
Comment 12•14 years ago
|
||
I'm pretty sure this is a bug in findReferences. The backtraces are always in the heap traversal that findReferences performs. That code does some unusual things with heap object references, so it's not entirely surprising that it might be buggy in the way that ASan is looking for.
Since findReferences is only included in the JS shell (in fact, it's in the js/src/shell directory, so it's unlikely to get incorporated into libxul.so by accident), I don't think this bug needs to be security-sensitive.
Comment 13•14 years ago
|
||
This is almost certainly a duplicate of Bug 755808.
Assignee: jimb → general
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
Version: Trunk → Other Branch
Updated•14 years ago
|
Keywords: sec-other
Whiteboard: js-triage-needed, [asan] → js-triage-needed, [asan] [sg:dupe 754146]
Updated•12 years ago
|
Group: core-security
You need to log in
before you can comment on or make changes to this bug.
Description
•