[quake3-bugzilla] [Bug 4283] New: Fix potential overlap of VM stack and bss sections

bugzilla-daemon at icculus.org bugzilla-daemon at icculus.org
Wed Feb 27 13:34:26 EST 2013


https://bugzilla.icculus.org/show_bug.cgi?id=4283

           Summary: Fix potential overlap of VM stack and bss sections
           Product: ioquake3
           Version: GIT MASTER
          Platform: All
        OS/Version: All
            Status: RESOLVED
          Severity: normal
          Priority: P3
         Component: Platform
        AssignedTo: zakk at icculus.org
        ReportedBy: baggett.patrick at gmail.com
         QAContact: quake3-bugzilla at icculus.org


Patrick Baggett <baggett.patrick at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE

It is possible for the Q3VM stack and data segment to overlap, which is very
bad. Below is the write up that I made a long time ago and mentioned once on
the mailing list but never filed a bug for:

Consulting vm.c:VM_LoadQVM()

If you see the definition of the "dataMask", you'll see it is the next highest
power of two that is greater than the sum of data, lit, and bss segments. So,
if the their sum was say, 400 bytes, then the next highest power of two would
be 512, and the mask would be 0x1FF (decimal 511). Let's continue with this
example. The stack grows down, and is implicity at the end of the image. This
means that the 

[data+lit+bss = 400][Extra space 112 bytes]

^------------------------------------------^ Whole allocation is 512 bytes.


Let's suppose the stack size was 256 bytes. This means:

                Stack size of 256 bytes
             v---------------------------v
[data+lit+bss = 400][Extra space 112 bytes]
^------------------^
             [ !!! ]

The area marked as [ !!! ] is the overlap of the two.

This can easily be fixed by changing the calculation of "dataLength" in vm.c
to:

dataLength = header.h->dataLength + header.h->litLength + header.h->bssLength +
STACK_SIZE;



This has not yet been a problem, but the closer the sum (header.h->dataLength +
header.h->litLength + header.h->bssLength) is to a power of two, the more
likely the error is to occur.

--- Comment #1 from Patrick Baggett <baggett.patrick at gmail.com> 2009-09-15 04:19:36 EDT ---
sorry, double post

*** This bug has been marked as a duplicate of bug 4282 ***

-- 
Configure bugmail: https://bugzilla.icculus.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the quake3-bugzilla mailing list