Closed Bug 945939 Opened 6 years ago Closed 6 years ago
Use-after-free or worse in Value
In ValueNumberer::lookupValue, we acquire a pointer |p| into the hashtable, then breakClass -- this may (and does in practice) modify the table -- then return p->value. If breakClass's modifications cause a table resize, p->value will return a random table entry, freed garbage, or even a different threads memory. This could cause an untold litany of immediate or subtle downstream damage, but is probably quite hard to exploit in practice. I think we want the pre-broken instruction id here instead, but I'm not familiar enough with our implementation of the algorithm to be 100% sure.
Attachment #8341956 - Flags: review?(sunfish)
Comment on attachment 8341956 [details] [diff] [review] fix_valuenumber-v0.diff Review of attachment 8341956 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jit/ValueNumbering.cpp @@ +40,5 @@ > return 0; > breakClass(ins); > } > > + return ins->id(); This function needs to return p->value in the case where the value was already in the map. Fortunately, there's no breakClass on that path, so that should be doable. Returning ins->id() looks correct only for the case where the item was not already present in the map.
Attachment #8341956 - Flags: review?(sunfish) → review-
Great! That's exactly what I needed to know.
Comment on attachment 8342454 [details] [diff] [review] fix_valuenumber-v1.diff Looks good to me. There's a patch conflict with the patch in bug 940033 but it should be trivial to resolve.
Attachment #8342454 - Flags: review?(sunfish) → review+
Comment on attachment 8342454 [details] [diff] [review] fix_valuenumber-v1.diff [Security approval request comment] How easily could an exploit be constructed based on the patch? Not easily. Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem? Not really. It's pretty subtle unless you're intimately familiar with the value numbering algorithm and our specific hashtable implementation. Which older supported branches are affected by this flaw? All of them. If not all supported branches, which bug introduced the flaw? Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be? This should be easy/trivial to backport. How likely is this patch to cause regressions; how much testing does it need? This shouldn't need more than a single green tbpl run to verify.
Attachment #8342454 - Flags: sec-approval?
Comment on attachment 8342454 [details] [diff] [review] fix_valuenumber-v1.diff (Discussed this with DVeditz). sec-approval+ for trunk. You should make an ESR and Aurora patches. Beta is too close to shipping.
Attachment #8342454 - Flags: sec-approval? → sec-approval+
Landed on m-i with a misleading summary. https://hg.mozilla.org/integration/mozilla-inbound/rev/0f3f132e2198
This was discovered through assertions; there is no way to test it.
Flags: in-testsuite? → in-testsuite-
Comment on attachment 8342454 [details] [diff] [review] fix_valuenumber-v1.diff Thanks for the heads-up, Ryan! I wasn't sure what the next step was. [Approval Request Comment] Bug caused by (feature/regressing bug #): Bug 723536. User impact if declined: A sec-high vulnerability. Testing completed (on m-c, etc.): Has been on m-c for a week. Risk to taking this patch (and alternatives if risky): Low. String or IDL/UUID changes made by this patch: None.
Comment on attachment 8342454 [details] [diff] [review] fix_valuenumber-v1.diff b2g28 = Aurora, so we're good :)
Attachment #8342454 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #8342454 - Flags: approval-mozilla-esr24? → approval-mozilla-esr24+
Comment on attachment 8342454 [details] [diff] [review] fix_valuenumber-v1.diff sec-highs tracking an ESR have automatic approval :)
Terrence, can you please advise QA on if/how we should verify this is fixed?
(In reply to Anthony Hughes, QA Mentor (:ashughes) from comment #15) > Terrence, can you please advise QA on if/how we should verify this is fixed? No verification is needed here. This flaw was discovered by manual analysis and there was never any attack crafted against it.
Thanks Terrence, tagging as [qa-]. Feel free to pre-emptively mark bugs not needing QA verification with [qa-] in the future.
Whiteboard: [qa-] → [qa-][adv-main27+][adv-esr24.3+]
You need to log in before you can comment on or make changes to this bug.