Status

()

defect
RESOLVED FIXED
13 years ago
10 years ago

People

(Reporter: bernd_mozilla, Assigned: bernd_mozilla)

Tracking

(Blocks 1 bug, 4 keywords)

Trunk
mozilla1.8.1
x86
Windows XP
Points:
---
Dependency tree / graph
Bug Flags:
blocking1.9a1 +
blocking1.8.1 +
blocking1.8.0.7 +
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [sg:critical] heap buffer underflow. fix rolled into 346980)

Attachments

(3 attachments, 1 obsolete attachment)

961 bytes, text/html
Details
6.15 KB, patch
Details | Diff | Splinter Review
8.75 KB, patch
bzbarsky
: review+
bzbarsky
: superreview+
Details | Diff | Splinter Review
Assignee

Description

13 years ago
the testcase tries to access foo[-1] or foo[0xffffffff] marking sensitive.
Assignee

Comment 1

13 years ago
Posted file testcase
Assignee: nobody → bernd_mozilla
Status: NEW → ASSIGNED
Assignee

Updated

13 years ago
Blocks: stirtable
Assignee

Comment 2

13 years ago
Posted patch patch (obsolete) — Splinter Review
Affects the 1.8 branches also, nominating.

Why do these routines use signed indexes? Could they be changed to use unsigned ints instead?
Flags: blocking1.9a1+
Flags: blocking1.8.1?
Flags: blocking1.8.0.6?
Whiteboard: [sg:critical] heap buffer underflow
Comment on attachment 228602 [details] [diff] [review]
patch

>-
>+  NS_ASSERTION(aFirstRowIndex >= 0, "nsCellMap::InsertRows called with negative rowIndex");

If you don't change the API's to use unsigned should we do more than assert? Add the assertion to other routines as well?

>   PRInt32 numRows = mRows.Count();
>   PRInt32 numCols = aMap.GetColCount();
> 
>   if (aFirstRowIndex >= numRows) {
>+    mRowCount -= aNumRowsToRemove;
>     return;

seems dodgy here, can mRowCount be made negative this way? Or has something else already incremented mRowCount by exactly the amount aFirstRowIndex is larger than numRows.

What if aFirstRowIndex is ever negative here? We didn't expect it could happen in the other place either.

>     if (aEndRowIndex < mRowCount - 1) {
>       cellData = GetDataAt(aMap, aEndRowIndex + 1, colX, PR_TRUE);
>       if ((cellData) && (cellData->IsRowSpan())) {
>         return PR_TRUE; // there is a row span out of the region
>       }
>     }
>+    else {
>+      // this cell might be the cause of a dead row which should be removed
>+      return PR_TRUE;
>+    }

"might be"? what happens if it isn't?
Assignee

Comment 5

13 years ago
>Why do these routines use signed indexes?
Because Chris wrote them. -1 is very common as a hidden boolean parameter to toggle function behaviour.

I haven't really analyzed the code what would happen with unsigned indices. I am currently more in panic mode trying to get the whole thing survive bug 339128. The upcoming patch does exactly this at least on my machine.

>seems dodgy here, can mRowCount be made negative this way? Or has something
>else already incremented mRowCount by exactly the amount aFirstRowIndex is
>larger than numRows.
Every row that we have increases mRowCount. Every row that we remove has to reduce it. We have a scenario where the latter does not happen without the patch.

>What if aFirstRowIndex is ever negative here? We didn't expect it could happen
>in the other place either.

If the routine returns PR_TRUE we will call a more expensive routine thats not a issue. 
Assignee

Comment 6

13 years ago
Posted patch patchSplinter Review
Attachment #228602 - Attachment is obsolete: true
Attachment #229215 - Flags: superreview?(bzbarsky)
Attachment #229215 - Flags: review?(bzbarsky)

Updated

13 years ago
Flags: blocking1.8.1? → blocking1.8.1+
I'd really like an explanation of what the various parts of the patch do to be able to review this...  For example, if aEndRowIndex >= mRowCount - 1, why is it ok to call GetDataAt(aMap, aEndRowIndex, colX, PR_TRUE)?  Why is the numOrigRows check needed?   That sort of thing.
Flags: blocking1.8.0.6? → blocking1.8.0.6+
Whiteboard: [sg:critical] heap buffer underflow → [sg:critical] [needs review bzbarsky] heap buffer underflow
Assignee

Comment 8

13 years ago
Posted patch revised patchSplinter Review
Attachment #231583 - Flags: superreview?(bzbarsky)
Attachment #231583 - Flags: review?(bzbarsky)
Assignee

Updated

13 years ago
Attachment #229215 - Flags: superreview?(bzbarsky)
Attachment #229215 - Flags: review?(bzbarsky)
Comment on attachment 231583 [details] [diff] [review]
revised patch

>--- nsCellMap.cpp	2006-08-01 16:26:40.296875000 +0200
>+++ nsCellMap.local	2006-08-01 16:33:42.140625000 +0200
>@@ -1498,30 +1502,51 @@ PRBool nsCellMap::CellsSpanOut(nsVoidArr
>+                                   // current cellmap extension.

s/extension/extent/ ?

>@@ -2023,18 +2048,23 @@ nsCellMap::RebuildConsideringRows(nsTabl

>+  PRInt32 copyEndRowIndex = PR_MIN(numOrigRows, aStartRowIndex);
>+
>   // put back the rows before the affected ones just as before
>-  for (rowX = 0; rowX < aStartRowIndex; rowX++) {
>+  // aStartRowIndex might be after all existing rows so we should limit the
>+  // copy to the amount of exisiting rows

Wouldn't this comment make more sense before you declare copyEndRowIndex and do the PR_MIN thing?

With that, looks ok.  Thanks for the comments!
Attachment #231583 - Flags: superreview?(bzbarsky)
Attachment #231583 - Flags: superreview+
Attachment #231583 - Flags: review?(bzbarsky)
Attachment #231583 - Flags: review+
Assignee

Comment 10

13 years ago
fixed on trunk
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Assignee

Updated

13 years ago
Blocks: 346980

Comment 11

13 years ago
Is this patch suitable for 1.8 branch?

Updated

13 years ago
Target Milestone: --- → mozilla1.8.1
Assignee

Comment 12

13 years ago
fixed on branch by the patch in bug 346980
Keywords: fixed1.8.1
Assignee

Comment 13

13 years ago
the only bug that should block 1.8.0.7 is bug 346980 which is blocked by the
regression 347725

asking for 1.8.0.7- on this

Comment 14

13 years ago
https://bugzilla.mozilla.org/attachment.cgi?id=228578&action=view
ff2b2 debug windows/linux no crash, no assert, nightly windows/linux no crash
verified fixed 1.8
Whiteboard: [sg:critical] [needs review bzbarsky] heap buffer underflow → [sg:critical] heap buffer underflow. fix rolled into 346980
Moving to 1.8.0.8 at Bernd's request (regression worries)
Flags: blocking1.8.0.8+
Flags: blocking1.8.0.7-
Flags: blocking1.8.0.7+
Assignee

Comment 16

13 years ago
fixed on branches by the cellmap branch patch
Keywords: fixed1.8.0.7
Can I get some clarification on this bug's status?  It seems to have been minus-ed for 1807, but it is marked 'fixed1807'.  Has the patch been checked in?  Has this issue been fixed by another patch?  Or are we planning on checking in this patch to the 1.8.0 branch later, even though this particular crash has been fixed?

This did land in 1.8.0.7 after all. It wasn't "blocking", but was still approved.
Flags: blocking1.8.0.8+
Flags: blocking1.8.0.7-
Flags: blocking1.8.0.7+
https://bugzilla.mozilla.org/attachment.cgi?id=228578&action=view should not crash

Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.7) Gecko/20060906 Firefox/1.5.0.7

verified 1.8.0.7
Group: security

Updated

12 years ago
Flags: in-testsuite?

Comment 20

10 years ago
crash test landed
http://hg.mozilla.org/mozilla-central/rev/5561696a146d
Flags: in-testsuite? → in-testsuite+
You need to log in before you can comment on or make changes to this bug.