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

From: Dave Hansen
Date: Mon Nov 05 2018 - 12:20:53 EST



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

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.