Re: [RFC PATCH v2 18/27] x86/cet/shstk: Introduce WRUSS instruction

From: Yu-cheng Yu
Date: Thu Jul 12 2018 - 19:03:42 EST


On Tue, 2018-07-10 at 16:48 -0700, Dave Hansen wrote:
> >
> > +/*
> > + * WRUSS is a kernel instrcution and but writes to user
> > + * shadow stack memory.ÂÂWhen a fault occurs, both
> > + * X86_PF_USER and X86_PF_SHSTK are set.
> > + */
> > +static int is_wruss(struct pt_regs *regs, unsigned long error_code)
> > +{
> > + return (((error_code & (X86_PF_USER | X86_PF_SHSTK)) ==
> > + (X86_PF_USER | X86_PF_SHSTK)) && !user_mode(regs));
> > +}
> I thought X86_PF_USER was set based on the mode in which the fault
> occurred.ÂÂDoes this mean that the architecture of this bit is different
> now?

Yes.

> That seems like something we need to call out if so.ÂÂIt also means we
> need to update the SDM because some of the text is wrong.

It needs to mention the WRUSS case.

>
> >
> > Âstatic void
> > Âshow_fault_oops(struct pt_regs *regs, unsigned long error_code,
> > Â unsigned long address)
> > @@ -848,7 +859,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
> > Â struct task_struct *tsk = current;
> > Â
> > Â /* User mode accesses just cause a SIGSEGV */
> > - if (error_code & X86_PF_USER) {
> > + if ((error_code & X86_PF_USER) && !is_wruss(regs, error_code)) {
> > Â /*
> > Â Â* It's possible to have interrupts off here:
> > Â Â*/
> This needs commenting about why is_wruss() is special.

Ok.