The default bug view has changed. See this FAQ.

nsXBLProtoImplProperty::InstallMember doesn't root correctly

RESOLVED FIXED

Status

()

Core
XBL
RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: dbaron, Assigned: dbaron)

Tracking

({fixed1.8.1, verified1.8.0.4})

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

Firefox Tracking Flags

(Not tracked)

Details

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

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

11 years ago
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.)
(Assignee)

Comment 1

11 years ago
Created attachment 212308 [details] [diff] [review]
patch

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)
(Assignee)

Updated

11 years ago
Whiteboard: [patch]
(Assignee)

Comment 2

11 years ago
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)
(Assignee)

Comment 3

11 years ago
Created attachment 212309 [details] [diff] [review]
patch
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]
patch

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+
(Assignee)

Comment 5

11 years ago
Fix checked in to trunk.
Status: NEW → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
(Assignee)

Comment 6

11 years ago
Filed comment 4 as bug 328007.
(Assignee)

Updated

11 years ago
Attachment #212309 - Flags: approval1.8.0.3?
Attachment #212309 - Flags: approval-branch-1.8.1?(bzbarsky)
Attachment #212309 - Flags: approval-branch-1.8.1?(bzbarsky) → approval-branch-1.8.1+
(Assignee)

Comment 7

11 years ago
Checked in to MOZILLA_1_8_BRANCH.
Keywords: fixed1.8.1

Comment 8

11 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 1.8.0.3.
Flags: blocking1.8.0.3+

Comment 9

11 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.
(Assignee)

Updated

11 years ago
Group: security
(Assignee)

Comment 11

11 years ago
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.

/be
Comment on attachment 212309 [details] [diff] [review]
patch

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

Comment 14

11 years ago
Fix checked in to MOZILLA_1_8_0_BRANCH.
Keywords: fixed1.8.0.3

Comment 15

11 years ago
v.fixed on 1.8.0 branch: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.0.2) Gecko/20060420 Firefox/1.5.0.2, 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.