Originally posted by: CTho9305
Originally posted by: bsobel
Why don't more OSes take advantage of the segment registers provided by x86
I think your asking why more OS's dont' take advantage of the ability to make memory read or read/write but not execute.
The answer is it's impossible to do this properly with the current x86 design. This is why MS added support in SP2 for the newer CPU's which do support this properly. I suspect will see more chips with this capability soon to take advantage of the change.
Bill
The bolded sentence is incorrect.
Lookie. Of course that patch alone isn't proof, but if you google a bit you'll find an explanation.
Look at the 286 section.
more info (note the "executable" bit).
Originally posted by: glugglug
How can a buffer overflow use the stack?
Everything that gets put on the stack is a value of KNOWN fixed size, generally no more than 4 bytes. Complex structures and variable length items like strings are NOT passed around on the stack, a pointer to them is. This pointer points to a memory location on the heap containing the string or structure....
Correct. That's the source of the whole problem. It happens when you allocate a fixed size buffer on the stack, then read in data from another source. For example, the following code is vulnerable to a buffer overflow exploit:
void foo(char *stringFromUser) {
char c[4];
strcpy(&c, stringFromUser);
}
c is allocated on the stack as 4 bytes. If the string from user is more than 4 bytes (including \0), the stack starts getting overwritten. At least using linux conventions, the first 4 bytes after c will be a saved register (ebp), followed by the return address, then stuff like saved registers. If your user enters a long string, and carefully crafts it, the return address can be made to point further up the stack, where the exploit code is located.