Re: [RFC PATCH] x86/mm/fault: Allow stack access below %rsp

From: Andy Lutomirski
Date: Mon Nov 05 2018 - 14:21:56 EST


On Mon, Nov 5, 2018 at 9:20 AM Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
>
>
> On 11/4/18 9:14 PM, Andy Lutomirski wrote:
> > I should add: if this patch is *not* applied, then I think we'll
> > need to replace the sw_error_code check with user_mode(regs) to avoid
> > an info leak if CET is enabled. Because, with CET, WRUSS will allow
> > a *kernel* mode access (where regs->sp is the kernel stack pointer)
> > with user permissions.
>
> Are you saying that WRUSS, if it faults will set the "user" page fault
> error code bit? I seem to have some rough recollection about it being
> that way, and the shadow-stack spec does say:
>
> paging access control checks will be treated as a user-mode
> shadow stack store
>

I believe so, and it would make sense for it to work this way. I
would love some instructions for directly accessing normal user
memory, too. Maybe a prefix?

> But the SDM says:
>
> For all instruction fetches and most data accesses, this
> distinction is determined by the current privilege level (CPL):
> accesses made while CPL < 3 are supervisor-mode accesses, while
> accesses made while CPL = 3 are user-mode accesses.
>
> It would certainly be ideal if things affecting the core architecture
> like this were in the SDM itself before we merged them. It makes things
> like this a lot easier to figure out.

Agreed. The current documentation situation is not so good.