![]() | |
| ||||
| Code: +------------------+ | Stack | | | +------------------+ | Free Space | | | : : : : +------------------+ | Heap | | | +------------------+ | Dlls | | | +------------------+ | Program.exe | +------------------+ The program is loaded first into the virtual memory at the bottom of the address space/model. This is a simple, single block of memory and at lease as large as the program size on disk. Windows systems support (and heavily use) Dynamic Load Libraries (DLL) and they get loaded very early in the program execution. The other three areas are quite dynamic in that they grow and shrink during the life of the program. The Free Space initially is adjacent to the top of the DLL space and runs up to the top of the virtual memory, and the Heap and Stack don't really exist at all. When the program runs any subroutine, a block of memory is added into the Stack at the top (which will expand downward towards the heap) and reduce the size of the Free Space from its top location. This block contains the parameters passed into the subroutine and the address of where the caller invoked the subroutine (and this is the value subject to stealing control during a buffer overrun). SubroutineA may call subroutineB and so on, pushing the stack further downward). Somewhere in the life of the program, one or more blocks of memory are needed:
Programs frequently use many dynamic areas and they get placed one upon the other pushing the Heap upward. These allocated areas tend to be kept throughout the life of the program so the Heap does not shrink unless the structure at the very top is released. Did you notice: The Heap grows upward and Stack grows downward; What happens if they collide or worse, one overlaps the other (call a Heap Overflow)? Nothing good for sure! The program will die with some nasty note recorded in the Event Viewer. I/O buffers are most frequently allocated from the heap, but sometimes, when the data is smallish and short lived, a program may push an I/O buffer onto the stack. The practice is no longer encouraged as any overrun jeopardizes the integrity of the entire stack. One last note, regarding 64bit systems. Some programs need LOTS of dynamic heap space for analysis of data. Typically these are mathematical in nature. Such programs quickly induce a Heap Overflow on 32bit systems. Thus the need for a 2^64 virtual address model.
__________________ J. O. Beard; you + tech-101.com => synergism. Secure your system now |
| ||||
| programming languages use bounds checking to make sure a variable is within X bounds before its used? [edit] Sorry; I saved on top of your post [/edit]
__________________ __________________ Check us out on Facebook!Useful Guides: Networking 101 Security 101 Disable Real Time Monitoring Virus/Malware Preliminary Removal Instructions Last edited by jobeard; 01-22-2010 at 11:38 AM. Reason: oops |
| ||||
| Quote:
Quote:
while we create a buffer of a fixed size, eg var buf = malloc(100); (buf then points to that space within the heap) there are i/o mechanisms that know nothing about the buffer size, eg: gets(buf), which will read until the NL char is found. Obviously, there's no assurity that the string will contain the NL before the end of the buffer. The preferred technique today is fgets(buf, 100, stdin) which will not read more than the size of the buf (ie the 100) In most systems, the boundaries of the Heap, Stack and Free space are not easily located EXCEPT by the memory management code of the OS (as it should be )
__________________ J. O. Beard; you + tech-101.com => synergism. Secure your system now |
| ||||
| Using this reference to my request to explain stack: Keeping in mind that I am not a programmer: Explain the security dangers and differences between a heap overflow and a stack overflow Users are frequently presented with an update because a vulnerability has been found in a stack overflow Keeping in mind that the heap overflows up and the stack overflows down, how can I explain this in a [non-technical[/b] way?
__________________ wave:Computer Support and Help Virus & Malware Removal Tutorials on "How To...." Stop Nuisance Startups |
| ||||
| Quote:
The stack overflow doesn't occur on a boundary violation at the lowest part of the stack, but rather on those small records created within the stack when subroutineA runs subroutineB. The overflow is not felt until subroutineB attempts to return to whoever called it (in this case A). The pointer to A is corrupted. (btw: This is also the same problem with the buffer overlow). Two things can occur
Quote:
The stack overflow is explained above. That's as simple as I can describe it and if it's still to technical -- I'm sorry.
__________________ J. O. Beard; you + tech-101.com => synergism. Secure your system now |
![]() |
| Tags |
| 64bit, buffer overrun, heap, stack |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Copyright © 2009 Tech-101.com. All rights reserved.