Re: Preventing Pentium Deaths

Linus Torvalds (torvalds@transmeta.com)
11 Nov 1997 05:20:44 GMT


In article <199711110432.XAA30273@jupiter.cs.uml.edu>,
Albert D. Cahalan <acahalan@cs.uml.edu> wrote:
>>
>> is just one simple example where the "magic bytes" are not
>> found by a memory scan. So why waste time?
>
>It is not wasting time. Your example is harmless, because you
>can't jump to the code you just created unless you have permission.
>Every time a page enters the state "in RAM with exec permission"
>the kernel can check.

Too bad that intel designed the CPU incorrectly for this in the first
place.

Intel CPU's don't have a 'x' bit in their page tables: any readable page
is executable.

That still leaves the segment crud, but gag me with a spoon, it's not
actually usable. Yes, you can try to use segments for execution, but
it's not going to work too well. Sane flat-programming-model semantics
essentially require that the data segment overlap the code segment (just
trust me - intel segments aren't flexible enough to do anything else),
which means that any code segment is essentially going to be writable
(not through the code segment itself, but through a data segment alias).

>Write+exec permission can be disabled. It is only used for
>buffer overrun exploits, trampolines, crashme, and other junk.

Sorry, you're wrong. Write+exec _cannot_ be disabled. You can disable
execution permissions on a very selective basis (make the code segment
be less than three GB, so that it doesn't contain the normal stack, for
example), but you cannot be selective enough.

Now, if you had an alpha, you could determine executability on a
page-per-page basis. Of course, if you had an alpha you wouldn't have
this problem in the first place, so..

Linus