[14799] in bugtraq

home help back first fref pref prev next nref lref last post

Re: Solaris 7 x86 lpset exploit.

daemon@ATHENA.MIT.EDU (Casper Dik)
Sat May 6 15:26:08 2000

Message-Id:  <200005031919.VAA23208@romulus.Holland.Sun.COM>
Date:         Wed, 3 May 2000 21:19:36 +0200
Reply-To: Casper Dik <Casper.Dik@HOLLAND.SUN.COM>
From: Casper Dik <Casper.Dik@HOLLAND.SUN.COM>
X-To:         der Mouse <mouse@RODENTS.MONTREAL.QC.CA>
To: BUGTRAQ@SECURITYFOCUS.COM
In-Reply-To:  Your message of "Wed, 03 May 2000 02:04:44 EDT." 
              <200005030604.CAA01307@Twig.Rodents.Montreal.QC.CA>

>If you longjmp out, how do you free up the jumped-through frames on the
>executable stack?  If you do it by using a contiguous executable stack
>with an offset-style pointer into it, conceptually the way longjmp
>deals with freeing ordinary stack frames, how do you deal with
>overflow, without wasting large amounts of data segment space on
>programs that don't need deep executable stacks?  If you do it with a
>linked list of frame structures, how do you push frames on it without
>risking either a corrupted stack or a lost frame in the presence of
>longjmp out of a signal handler?  If you do it with something else,
>well, what?

Not to mention the fact that building a second stack in the data
segment is *much* harder to do in a threaded environment.  You need
one stack per thread.

>Someone else said - I don't have the quote handy - that modern gcc
>calls mprotect() after setting up a trampoline.  The notion of doing a
>*syscall* per entry to a routine that uses trampolines, even when the
>system may not need it (may have the stack executable already), that
>makes me shudder.  I trust this can be turned off at compile time?  I'd
>really hate to have to dummy out mprotect() just to get minimally sane
>call performance.  (Oh, and what gcc version is that?)

It's not quite that bad.  First of all, the tampolines are
the exception.  They're only needed when you pass a nested function
as a parameter.  Perhaps only in C, as in other languages you can define
the ABI such that a function pointer is larger.  And in C, you shouldn't
be using nested functions in the first place.

Secondly, the code will use a syscall to determine whether the stack
is executable or not.  The result of this call is cached.  Mprotect
is only called when it is required.

Note that the trampoline code is already heavily dependent on the kernel;
in some cases the routines that flush the icache lines trap into the
kernel anyway.

Casper

home help back first fref pref prev next nref lref last post