Closed Bug 975387 Opened 7 years ago Closed 7 years ago
Composition should clear m Pres Context when the Pres Context is destroyed
This may be dangerous. The TextComposition::mPresContext may be referred after destroyed. We should fix this bug on Aurora too.
I realized this bug when I was writing a patch for another bug. Therefore, I'm not sure this bug actually causes crash or something. At compositionstart event handler, JS may do something to destroy its presContext. Then, mPresContext may be already released. However, when this method is called, the caller's PresShell is held by nsViewManager with local variable: http://mxr.mozilla.org/mozilla-central/source/view/src/nsViewManager.cpp#751 And PresShell::mPresContext must be alive while PresShell instance is alive because its destructor releases mPresContext: http://mxr.mozilla.org/mozilla-central/source/layout/base/nsPresShell.cpp#769 Although, I don't know the reason why PresShell checks mPresContext at a lot of plases... So, I think that this is safe, but may not be so in the future. So, we should make a wall with this patch.
Comment on attachment 8379751 [details] [diff] [review] Patch [Security approval request comment] How easily could an exploit be constructed based on the patch? As I said in my previous comment, the mPresContext is always held luckily. Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem? The check-in comment might be so. I'd like you to suggest other commit message if you think it's bad. Which older supported branches are affected by this flaw? Aurora has this bug too. Beta and Release don't have this. If not all supported branches, which bug introduced the flaw? The referencing code of mPresContext after dispatching an event is added by bug 935821. Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be? It's easy. I'll post the patch for Aurora soon. How likely is this patch to cause regressions; how much testing does it need? Even if this causes regressions, it's only affected to e10s. But e10s hasn't supported IME completely yet.
[Approval Request Comment] Bug caused by (feature/regressing bug #): Bug 935821 User impact if declined: As far as I researched, this doesn't cause actual trouble. But this makes a wall for the dangerous scenario. Testing completed (on m-c, etc.): Not yet landed on m-c. Waiting sec-approval. Risk to taking this patch (and alternatives if risky): No idea. After nsIMEStateManager stops managing TextComposition instances, they shouldn't be used for dispatching any events. (Others cannot retrieve the destroyed instance in expected scenarios) String or IDL/UUID changes made by this patch: Nothing.
Comment on attachment 8379751 [details] [diff] [review] Patch Hmm, I'm sorry. I found this patch is not enough.
Comment on attachment 8380472 [details] [diff] [review] Patch for Aurora cancelling the request because I found that this is not enough.
Comment on attachment 8379751 [details] [diff] [review] Patch Sorry for the spam. I misunderstood as that nsIMEStateManager::DispatchCompositionEvent() will create new composition with destroyed PresContext. However, I confirmed that my concern is wrong. So, this patch's wall works as I expected. Please see comment 3 for the sec-approval.
Anyway, we need to redesign the cases at destroying a document from composition event handlers. Even with these patches, IME state is still confused even in the next focused editor.
Comment on attachment 8379751 [details] [diff] [review] Patch sec-approval+ for trunk. I'm not concerned about the commit message as long as we take this on Aurora as well.
Attachment #8379751 - Flags: sec-approval? → sec-approval+
Attachment #8380472 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
(In reply to Al Billings [:abillings] from comment #10) > sec-approval+ for trunk. I'm not concerned about the commit message as long > as we take this on Aurora as well. Thank you for the sec-review. You said "sec-approval+ for trunk", but you gives + for approval-mozilla-aurora too. Can I land them now? Or do I need to request sec-review for tha patch for Aurora again?
Once you have sec-approval for trunk, the patches can be landed anywhere, as long as they go through the usual approval process. So the patch can be landed immediately on trunk and Aurora. The idea is that once a patch lands on any branch, a bad guy could see it, so it doesn't matter much from a security perspective if it lands on other branches, too.
Thank you, I'll land them after lunch.
The tree rules are clear that you are not to double-land patches on Aurora and inbound. Please wait until the patch has stuck on trunk before uplifting. Also, when landing on the release branches, please set the status flag appropriately.
(In reply to Ryan VanderMeulen [:RyanVM UTC-5] from comment #16) > The tree rules are clear that you are not to double-land patches on Aurora > and inbound. Please wait until the patch has stuck on trunk before > uplifting. Also, when landing on the release branches, please set the status > flag appropriately. I see. Thank you for your explanation.
Yes, generally "sec-approval+" is an approval for trunk landing. After it lands on trunk, you can get approval for any branch patches as necessary. We want it to go green on trunk though.
Marking [qa-] due to lack of test case, but feel free to provide one if you'd like verification. Thanks.
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.