Hi David,<div><br></div><div>Thank you for confirming that for me.</div><div><br></div><div>What about the plausibility of splitting the single alloca space (the one stack) into three sections, with a "guard page" between each of the sections? Does LLVM provide the capabilities required to do this or something similar?</div>
<div><br></div><div>I simply need "something" to ensure that if X is on stack1 and Y is on stack2 that an access to X cannot access Y.</div><div><br></div><div>Thank you,</div><div><br></div><div>~Brent Roth~<br>
<br><div class="gmail_quote">On Mon, Jun 3, 2013 at 9:25 AM, David Chisnall <span dir="ltr"><<a href="mailto:David.Chisnall@cl.cam.ac.uk" target="_blank">David.Chisnall@cl.cam.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Brent,<br>
<br>
You're correct.  The segmented stack model is intended for performance, not security.  Its goal is to allow lightweight threads to be very cheaply allocated and destroyed.<br>
<br>
For your model, you would most likely want to use different address spaces for the different memory types.  Currently, clang does not allow you to define the address space of variables with automatic storage ('stack variables') and I'm not sure if this is a limitation of LLVM's alloca instruction or of the front end.<br>

<br>
David<br>
<div><div class="h5"><br>
On 3 Jun 2013, at 14:02, Brent Gregory Roth <<a href="mailto:brent.gregory.roth@gmail.com">brent.gregory.roth@gmail.com</a>> wrote:<br>
<br>
> Hi Duncan,<br>
><br>
> It doesn't appear to be what I'm looking for as there is copying of the old stack to the new stack. Additionally, according to the LLVM docs on segmented stacks (<a href="http://llvm.org/releases/3.0/docs/SegmentedStacks.html" target="_blank">http://llvm.org/releases/3.0/docs/SegmentedStacks.html</a>) the stacklings are allocated memory from the heap. Since this places them all on the same memory segment, a read/write from one stackling could technically overflow to read/write another stackling ... unless there is something I've overlooked or is undocumented.<br>

><br>
> What I've been looking at currently is a suggestion made to me last night to either<br>
> (1) modify the allocated space for local variables in LLVM so that there are multiples of them<br>
> (2) treat all local variables as globals and specify explicitly where each should be written<br>
><br>
> The primary goal I'm trying to achieve is such that a read/write to one or more variables on one stack cannot overflow to those on another stack due to either a protection page in between and/or implicit protections from being on different memory segments.<br>

><br>
> Thank you,<br>
><br>
> ~Brent Roth~<br>
><br>
> On Mon, Jun 3, 2013 at 8:33 AM, Duncan Sands <<a href="mailto:baldrick@free.fr">baldrick@free.fr</a>> wrote:<br>
> Hi Brent,<br>
><br>
><br>
> On 03/06/13 14:32, Brent Gregory Roth wrote:<br>
> Hi Duncan,<br>
><br>
> Are the segmented stacks actually on separate memory segments? My intended<br>
> purpose for placing different datatypes on separate stacks is such that memory<br>
> accesses to one datatype won't be allowed to overflow to another datatype.<br>
><br>
> If they aren't, in fact, on separate memory segments, are you aware of a way to<br>
> place a non-readable/-writable segment in between two other stack segments?<br>
><br>
> it is essentially the same thing as GCC's split stacks:<br>
><br>
> <a href="http://gcc.gnu.org/wiki/SplitStacks" target="_blank">http://gcc.gnu.org/wiki/SplitStacks</a><br>
><br>
> Ciao, Duncan.<br>
><br>
><br>
> Thanks,<br>
><br>
> ~Brent Roth~<br>
><br>
> On Mon, Jun 3, 2013 at 3:20 AM, Duncan Sands <<a href="mailto:baldrick@free.fr">baldrick@free.fr</a><br>
> <mailto:<a href="mailto:baldrick@free.fr">baldrick@free.fr</a>>> wrote:<br>
><br>
>     Hi Brent, LLVM supports segmented stacks, I suggest you do a case<br>
>     insensitive grep for segmented.stack in the source code (the . is<br>
>     to match any character).<br>
><br>
>     Ciao, Duncan.<br>
><br>
><br>
>     On 03/06/13 00:35, Brent Gregory Roth wrote:<br>
><br>
>         Greetings,<br>
><br>
>         First, my apologies if I have incorrectly used any of these lists.<br>
><br>
>         I'm sending this email in order to get some help on where in the<br>
>         codebases for LLVM and/or Clang I should be looking in order to<br>
>         accomplish the following:<br>
><br>
>         - create 4 additional memory segment<br>
>         - - 2 to be used as "additional stacks"<br>
>         - - 2 to be used as "additional heaps"<br>
><br>
>         - modify the stack frame and stack pointer registers (in order to make<br>
>         use of the 2 "additional stacks")<br>
><br>
>         - modify segment descriptors, as needed, to support reads/writes to the<br>
>         additional segments<br>
><br>
>         - modify which stack variables go to which of the three stacks<br>
>         - - same for heaps<br>
><br>
>         Thank you.<br>
><br>
>         Sincerely,<br>
><br>
>         ~Brent Roth~<br>
>         _________________________________________________<br>
>         LLVM Developers mailing list<br>
>         <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <mailto:<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>

>         <a href="http://lists.cs.uiuc.edu/__mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/__mailman/listinfo/llvmdev</a><br>
>         <<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>><br>
><br>
><br>
>     _________________________________________________<br>
>     LLVM Developers mailing list<br>
>     <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <mailto:<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>

>     <a href="http://lists.cs.uiuc.edu/__mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/__mailman/listinfo/llvmdev</a><br>
>     <<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>><br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
</div></div>> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
</blockquote></div><br></div>