nsXBLProtoImplProperty::InstallMember doesn't root correctly




13 years ago
13 years ago


(Reporter: dbaron, Assigned: dbaron)


({fixed1.8.1, verified1.8.0.4})

fixed1.8.1, verified1.8.0.4
Bug Flags:
blocking1.7.14 ?
blocking-aviary1.0.9 ?
blocking1.8.0.4 +

Firefox Tracking Flags

(Not tracked)


(Whiteboard: [sg:critical?][patch])


(1 attachment, 1 obsolete attachment)

nsXBLProtoImplProperty::InstallMember doesn't root correctly because it doesn't give its temporary variable a name!  (LXR says this is the only use of nsAutoGCRoot with this problem.)
Created attachment 212308 [details] [diff] [review]

The first chunk is the important one, the rest is cleanup that I've had in my tree for ages (the call used to require a cx argument, it no loner does).
Attachment #212308 - Flags: superreview?(bzbarsky)
Attachment #212308 - Flags: review?(bzbarsky)
Actually, we need to root the setter too, because DefineUCProperty can cause GC:

js_GC (/builds/trunk/mozilla/js/src/jsgc.c:1947)
js_NewGCThing (/builds/trunk/mozilla/js/src/jsgc.c:635)
AllocSlots (/builds/trunk/mozilla/js/src/jsobj.c:1925)
js_NewObject (/builds/trunk/mozilla/js/src/jsobj.c:2052)
js_CloneFunctionObject (/builds/trunk/mozilla/js/src/jsfun.c:2070)
JS_CloneFunctionObject (/builds/trunk/mozilla/js/src/jsapi.c:3414)
xpc_CloneJSFunction(XPCCallContext&, JSObject*, JSObject*) (/builds/trunk/mozilla/js/src/xpconnect/src/xpcwrappednativeinfo.cpp:56)
DefinePropertyIfFound (/builds/trunk/mozilla/js/src/xpconnect/src/xpcwrappednativejsops.cpp:453)
XPC_WN_ModsAllowed_Proto_Resolve (/builds/trunk/mozilla/js/src/xpconnect/src/xpcwrappednativejsops.cpp:1574)
js_LookupPropertyWithFlags (/builds/trunk/mozilla/js/src/jsobj.c:2801)
js_LookupProperty (/builds/trunk/mozilla/js/src/jsobj.c:2660)
js_DefineNativeProperty (/builds/trunk/mozilla/js/src/jsobj.c:2524)
js_DefineProperty (/builds/trunk/mozilla/js/src/jsobj.c:2469)
DefineUCProperty (/builds/trunk/mozilla/js/src/jsapi.c:2381)
Created attachment 212309 [details] [diff] [review]
Attachment #212308 - Attachment is obsolete: true
Attachment #212309 - Flags: superreview?(bzbarsky)
Attachment #212309 - Flags: review?(bzbarsky)
Attachment #212308 - Flags: superreview?(bzbarsky)
Attachment #212308 - Flags: review?(bzbarsky)
Comment on attachment 212309 [details] [diff] [review]

r+sr=bzbarsky, but we need similar changes to root newly-cloned function objects across JS_DefineUCProperty in nsXBLProtoImplMethod::InstallMember and the code added in bug 307040.

It looks like thanks to the wonders of XPConnect, Brendan's bug 299205 comment 10 is not quite right.  :(

We probably want this on both 1.8 branches.
Attachment #212309 - Flags: superreview?(bzbarsky)
Attachment #212309 - Flags: superreview+
Attachment #212309 - Flags: review?(bzbarsky)
Attachment #212309 - Flags: review+
Fix checked in to trunk.
Last Resolved: 13 years ago
Resolution: --- → FIXED
Attachment #212309 - Flags: approval-branch-1.8.1?(bzbarsky) → approval-branch-1.8.1+

Comment 8

13 years ago
Can we get some info about how this affect people in the wild?  How will this  benefit the users?  We need this benefit before we can approve the patch for
Flags: blocking1.8.0.3+

Comment 9

13 years ago
Since some null checks are being removed by this patch, we'd like a little more clarity w.r.t. risk before accepting this patch.  Can someone please address Tim's question (comment #8).  Thanks!
> Since some null checks are being removed by this patch,

The null checks being removed were holdovers from back when we actually used the |cx| object there (to root stuff).  We don't anymore, so it's not an issue whether cx is null (not that it ever can be in this case).

As for comment 8, this just makes sure we don't access deleted objects by keeping them alive while we're working with them.  The effect should be fewer random exploitable deleted-memory-access crashes and nothing else.
The null-check removals were just cleanup -- very low risk cleanup, though.  But I could easily skip that part of the patch for a 1.8.0 branch landing.
For crying out loud...

Read http://lxr.mozilla.org/mozilla/source/content/base/src/nsContentUtils.cpp#2552 and note that there is no dependency on a (JSContext *) cx cast from any aContext that is *not* passed to nsContentUtils::AddJSGCRoot.

The whole GetNativeContext call, assignment to cx, and test of cx are useless.  The patch should be taken in full, fiddling to remove these null check removals is a waste of time and a minor but non-zero merge hazard.

Comment on attachment 212309 [details] [diff] [review]

approved for 1.8.0 branch, a=dveditz for drivers
Attachment #212309 - Flags: approval1.8.0.3? → approval1.8.0.3+

Comment 15

13 years ago
v.fixed on 1.8.0 branch: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv: Gecko/20060420 Firefox/, based on code inspection and brendan's comments.
Keywords: fixed1.8.0.3 → verified1.8.0.3
Whiteboard: [patch] → [sg:critical?][patch]
Flags: blocking1.7.14?
Flags: blocking-aviary1.0.9?
Group: security
You need to log in before you can comment on or make changes to this bug.