lkml.org 
[lkml]   [2020]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [NEEDS-REVIEW] Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack
From
Date
On 9/14/2020 11:31 AM, Andy Lutomirski wrote:
>> On Sep 14, 2020, at 7:50 AM, Dave Hansen <dave.hansen@intel.com> wrote:
>>
>> On 9/11/20 3:59 PM, Yu-cheng Yu wrote:
>> ...
>>> Here are the changes if we take the mprotect(PROT_SHSTK) approach.
>>> Any comments/suggestions?
>>
>> I still don't like it. :)
>>
>> I'll also be much happier when there's a proper changelog to accompany
>> this which also spells out the alternatives any why they suck so much.
>>
>
> Let’s take a step back here. Ignoring the precise API, what exactly is
> a shadow stack from the perspective of a Linux user program?
>
> The simplest answer is that it’s just memory that happens to have
> certain protections. This enables all kinds of shenanigans. A
> program could map a memfd twice, once as shadow stack and once as
> non-shadow-stack, and change its control flow. Similarly, a program
> could mprotect its shadow stack, modify it, and mprotect it back. In

What if we do the following:

- If the mapping has VM_SHARED, it cannot be turned to shadow stack.
Shadow stack cannot be shared anyway.

- Only allow an anonymous mapping to be converted to shadow stack, but
not the other way.

> some threat models, though could be seen as a WRSS bypass. (Although
> if an attacker can coerce a process to call mprotect(), the game is
> likely mostly over anyway.)
>
> But we could be more restrictive, or perhaps we could allow user code
> to opt into more restrictions. For example, we could have shadow
> stacks be special memory that cannot be written from usermode by any
> means other than ptrace() and friends, WRSS, and actual shadow stack
> usage.
>
> What is the goal?

There primary goal is to allocate/mmap a shadow stack from user space.

>
> No matter what we do, the effects of calling vfork() are going to be a
> bit odd with SHSTK enabled. I suppose we could disallow this, but
> that seems likely to cause its own issues.
>

Do you mean vfork() has issues with call/return? That is taken care of
in GLIBC. Or do you mean it has issues with mprotect(PROT_SHSTK)?

\
 
 \ /
  Last update: 2020-09-14 22:45    [W:0.251 / U:3.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site