Closed Bug 679593 Opened 13 years ago Closed 13 years ago

Possible JSScript double-free

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
firefox5 - wontfix
firefox6 - wontfix
firefox7 - wontfix
firefox8 + fixed
firefox9 + fixed
status1.9.2 --- unaffected

People

(Reporter: billm, Assigned: billm)

Details

(Whiteboard: [sg:critical?], wanted-standalone-js [qa-])

Attachments

(1 file)

The problem is in js_CloneFunctionObject. Consider the cross-compartment case where we're clonging |fun|. We create a new function |cfun| and do:
  cfun->u = fun->getFunctionPrivate()->u;
For an interpreted script, this makes cfun->script() == fun->script(). Then we do
  JSScript *cscript = js_CloneScript(cx, script);
and, after a null check on cscript, make |cfun->script() == cscript|.

Say that we fail to allocate cscript. Then we'll have two allocated function objects, in different compartments, pointing to the same script. This is bad because of the compartment thing and also because each function object finalizer will free the script, so it will be freed twice.
Assignee: general → wmccloskey
Whiteboard: [sg:critical?]
Attached patch fixSplinter Review
This was totally my fault. I changed this recently and it was a bad idea. This should fix it.
Attachment #554933 - Flags: review?(dmandelin)
Attachment #554933 - Flags: review?(dmandelin) → review+
Whiteboard: [sg:critical?] → [sg:critical?][inbound]
http://hg.mozilla.org/mozilla-central/rev/c8eea83232b2
Status: NEW → RESOLVED
Closed: 13 years ago
OS: Linux → All
Hardware: x86 → All
Resolution: --- → FIXED
Whiteboard: [sg:critical?][inbound] → [sg:critical?]
Version: unspecified → Trunk
Is this patch good for aurora and beta? If so, please request approvals.
Comment on attachment 554933 [details] [diff] [review]
fix

There's a very slight possibility that this is broken in beta. It's definitely broken in aurora. I'm not sure how significant a problem this actually is, but it's unlikely to regress anything so we should probably get it in.
Attachment #554933 - Flags: approval-mozilla-beta?
Attachment #554933 - Flags: approval-mozilla-aurora?
Attachment #554933 - Flags: approval-mozilla-beta?
Attachment #554933 - Flags: approval-mozilla-beta-
Attachment #554933 - Flags: approval-mozilla-aurora?
Attachment #554933 - Flags: approval-mozilla-aurora+
Bill, can you get this landed on aurora, we've only got a few days left!
Whiteboard: [sg:critical?] → [sg:critical?], wanted-standalone-js
This landed in aurora before the most recent uplift, which means it's fixed for 8! Marking so.
qa- as nothing to do for QA fix verification -- please set to qa+ if this is not the case.
Whiteboard: [sg:critical?], wanted-standalone-js → [sg:critical?], wanted-standalone-js [qa-]
The 1.9.2 code is significantly different and there's no testcase, assuming 3.6.x is OK.
Group: core-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: