[comp.os.minix] Idea for sep. data & stack segs.

mike.irons@lynx.northeastern.edu (06/04/91)

	I just had an idea that would allow (I think) seperate segments for the
stack and data segments on Intel x86 (x >= 2). Have seperate, OVERLAPPING s
segments. With this the pointers to the stack and data would be for different
selectors, but the descriptors would address the same space. With this the stack 
segment  'top' could be used to detect stack over-runs.

	How hard, if workable, would this be?

					mike.irons@lynx.northeastern.edu
				
acm118@dworkin.ccs.northeastern.edu

Christoph van Wuellen <HBO043%DJUKFA11.BITNET@cunyvm.cuny.edu> (06/05/91)

How do you decide, if a pointer is given to a function, if it
should point to the stack or to the data segment?

This only works if stack and data are far (ca. 4 GByte) away so you can
tell a (legal) stack-low condition from an illegal access beyond the
data segment border (e.g. by assuming that accesses to the upper 2 GByte
reference the stack segment).

If ANY access beyond the current brk value just allocates space for the
stack, this is of no use.

C.v.W.

hp@vmars.tuwien.ac.at (Peter Holzer) (06/06/91)

mike.irons@lynx.northeastern.edu writes:


>	I just had an idea that would allow (I think) seperate segments for the
>stack and data segments on Intel x86 (x >= 2). Have seperate, OVERLAPPING s
>segments. With this the pointers to the stack and data would be for different
>selectors, but the descriptors would address the same space. With this the stack 
>segment  'top' could be used to detect stack over-runs.

>	How hard, if workable, would this be?

It wouldn't be hard, but I don't see any benefit in it. Stack segments
always start at 64k (or 4G on the 386) and grow downward. If you want
to dereference pointers without checking against segment boundaries
first (I guess you want to, or you wouldn't have proposed starting both
segments at the same address), the data segment would have to be
exactly 64k (4G) in length. So you would gain the ability to detect
stack overruns, but loose the ability to chmem the program, trap on
dereferencing pointers that point outside your address space (because
there is no `outside' anymore, and on the 386, every program could even
access all memory. Of course, on the 386, you could use paging and map
only those pages that belong to your process, but then you don't need
segments.

--
|    _  | Peter J. Holzer                       | Think of it   |
| |_|_) | Technical University Vienna           | as evolution  |
| | |   | Dept. for Real-Time Systems           | in action!    |
| __/   | hp@vmars.tuwien.ac.at                 |     Tony Rand |