Re: Easily and Permanently prevent all stack buffer overflows
- From: default <joel_seidmanNOSPAME@xxxxxxxxx>
- Date: Sat, 17 Nov 2007 02:34:11 -0000
On Fri, 16 Nov 2007 04:12:53 -0800, Abut wrote:
On Nov 14, 4:31 am, Wayne <nos...@xxxxxxxxxxxxxx> wrote:You're not missing something -- you're right. The entity that defines the
I've often wondered why Linux (or any OS) puts up with
stack buffer overflows. They only happen because
the stack grows in one direction and buffers grow
in the other:
+----------------------------------------------------+
| unused stack space | buf | ... | return_addr | ... |
+----------------------------------------------------+
Lower memory address ----> Higher memory address
where buf is some local char array. A buffer
overflow (in the case, there are heap attacks too)
is only possible if a user over-writes the return
address or some other part of the "lower" stack
contents.
So why doesn't any OS define the stack growth in the
other direction:
+----------------------------------------------------+
| ... | return_addr | ... | buf | unused stack space |
+----------------------------------------------------+
Lower memory address ----> Higher memory address
-Wayne
Surely this is a function of the x86 architecture? PUSH is defined to
write the PUSHed register to the address pointed to by the stack
pointer, and then to *decrement* the stack pointer. POP reads from the
pointed-to address, and *increments* the stack pointer.
I don't see how any OS could realistically do it any differently on
that architecture - but perhaps I am missing something?
instruction set architecture specifies the calling conventions for
subroutines, including use of the stack for local variables, parameter
passing and return address. The compiler developer must follow the
specification (if not, different compilers won't interoperate). The OS
comes along well after (esp. Linux) and has no say. (In the distant past,
compiler and OS and ISA were co-developed by the same entity, as in the
case of the DEC VAX. I don't know of a recent example. Actually, there
haven't been too many new ISA's coming along lately.)
.
- References:
- Prev by Date: Re: Easily and Permanently prevent all stack buffer overflows
- Next by Date: Re: Security and manageability minded LiveCD?
- Previous by thread: Re: Easily and Permanently prevent all stack buffer overflows
- Index(es):
Relevant Pages
|