Closed Bug 343850 Opened 19 years ago Closed 19 years ago

Crash [@ nsHTMLSharedObjectElement::StartObjectLoad] [@ nsObjectLoadingContent::LoadObject]

Categories

(Core Graveyard :: Plug-ins, defect)

defect
Not set
critical

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: jruderman, Assigned: bzbarsky)

References

Details

(Keywords: crash, testcase, Whiteboard: [sg:critical] post-1.8 regression?)

Crash Data

Attachments

(5 files, 1 obsolete file)

Loading the testcase makes Firefox crash. Based on some stack traces having random addresses on top, this is [sg:critical].
Attached file testcase
Flags: blocking1.9a1?
Whiteboard: [sg:critical]
This is why I said this is [sg:critical]. The testcase I attached is simpler and usually makes it look like a null deref.
Wow, first time I've ever tripped WinXP's Data Execution Protection from one of these memory corruption crashes. I was beginning to think DEP didn't work :-) If you're getting different crashes maybe the "related testcase" should be attached as well? Getting stopped by DEP is plenty evidence that *this* testcase is exploitable, I just worry maybe there's a second bug hiding in your other testcase. Didn't crash in Bon Echo, is this a 1.9-only regression?
Whiteboard: [sg:critical] → [sg:critical] post-1.8 regression?
Attached file trace
We save a raw pointer to the channel here: http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/content/base/src/nsObjectLoadingContent.cpp&rev=1.33&root=/cvsroot&mark=977#926 This doesn't work well with nsJSChannel: http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp&rev=1.128&root=/cvsroot&mark=534,546,598#529 which only temporarily is part of the load group, but later "delegates" the request to its |mStreamChannel|. The problem with this is that there is no strong ref on the nsJSChannel object itself so when |chan| goes out of scope in nsObjectLoadingContent::LoadObject it is destroyed and |mChannel| is a stray pointer.
OS: Mac OS X 10.4 → All
Hardware: Macintosh → All
Attached patch wip (obsolete) — Splinter Review
I don't know this code very well, but this fixes the crash. Instead of saving |mChannel| in LoadObject() we do it in OnStartRequest() where the |aRequest| is the |mStreamChannel| that nsJSChannel delegated the request to.
Blocks: 343943
Attached patch Patch rev. 2Splinter Review
Get rid of 'mChannel', this should make the code more robust I think.
Attachment #228488 - Attachment is obsolete: true
Attachment #228601 - Flags: review?(cbiesinger)
I really don't like this fix... what's wrong with the existing code?
oh, missed comment 5. Isn't that a bug in the channel implementation?
Yeah, this is a bug in the channel impl, as I understand the channel API. There should be an OnChannelRedirect notification sent here or something... That said, nsIChannel doesn't explicitly say that the channel itself is passed to the On*Request methods of the nsIStreamListener, does it? It probably should.
nsJSChannel does lots of things to violate the nsIChannel API, like calling nsILoadGroup::RemoveRequest from AsyncOpen :-(
Right. I'm saying we should fix those. And document more clearly that these _are_ violations of the API.
> Right. I'm saying we should fix those. And document more clearly that these > _are_ violations of the API. I tried once, and it caused loads of regressions. The problem is that javascript: evaluation can cause nsDocShell::LoadURI to be called, and evaluation has to happen during AsyncOpen for some reason. There's really not much hope of implementing a sane nsJSChannel IMO :-/ It almost seems like javascript: shouldn't be implemented as a nsIChannel.
Evaluation "has" to happen during AsyncOpen because script expects setting something's URI to javascript: to synchronously run the script. :( If we can make it not be an nsIChannel, that would be great, but the problem is that it can return data that should then be loaded.... All that said, maybe we can make this suck a little less in a slightly less painful way. Lemme give it a shot.
Better document the requirements on nsIChannel and make nsJSChannel closer to those by having it be the listener for the stream channel. The one issue I see here is mention of the unfrozen nsIChannelEventSink interface in nsIChannel. I'm really not sure how to document the expected behavior without that, though. :(
Attachment #229388 - Flags: review?(darin)
Comment on attachment 228601 [details] [diff] [review] Patch rev. 2 I'll mark this r- for now because I don't think this is the way to go.
Attachment #228601 - Flags: review?(cbiesinger) → review-
I don't crash on the testcase with a recent 1.8.0.5 build nor with a recent 1.8.1 build.
Comment on attachment 229388 [details] [diff] [review] Attempted fix to nsJSChannel "If the notification callbacks do not provide an nsIChannelEventSink" ... you should probably also mention the nsILoadGroup's notification callbacks to be clear. This patch makes sense to me. r=darin
Attachment #229388 - Flags: review?(darin) → review+
Attachment #229388 - Flags: superreview?(jst)
Comment on attachment 229388 [details] [diff] [review] Attempted fix to nsJSChannel sr=jst
Attachment #229388 - Flags: superreview?(jst) → superreview+
Changed that paragraph to: * If the channel's and loadgroup's notification callbacks do not provide * an nsIChannelEventSink when onChannelRedirect would be called, that's * equivalent to having called onChannelRedirect. and fixed on trunk.
Assignee: nobody → bzbarsky
Target Milestone: --- → mozilla1.9alpha
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
sorry for commenting late, but: + // Make sure to drop our ref to mListener + nsCOMPtr<nsIStreamListener> listener; + listener.swap(mListener); + + NS_ENSURE_TRUE(aRequest == mStreamChannel, NS_ERROR_UNEXPECTED); shouldn't the NS_ENSURE_TRUE be above the listener swapping?
No, that's where the "Make sure to drop our ref to mListener" thing comes in... Though we probably _should_ null-check |listener| before calling things on it. I'll check in that change.
Actually, I guess if we want this to work in the face of someone maliciously calling random methods on the nsJSChannel while it's loading we do need to change the order...
Made the order change.
Group: security
Flags: wanted1.8.1.x-
Flags: wanted1.8.0.x-
Flags: blocking1.9a1?
Crashtest checked in.
Flags: in-testsuite+
Crash Signature: [@ nsHTMLSharedObjectElement::StartObjectLoad] [@ nsObjectLoadingContent::LoadObject]
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: