Re: [PATCH v3 27/37] x86/shstk: Introduce routines modifying shstk

Peter Zijlstra
2022-11-16T10:19:15Z

On Tue, Nov 15, 2022 at 11:42:46PM +0000, Edgecombe, Rick P wrote:
> On Tue, 2022-11-15 at 15:18 +0100, Peter Zijlstra wrote:
> > On Fri, Nov 04, 2022 at 03:35:54PM -0700, Rick Edgecombe wrote:
> >
> > > +#ifdef CONFIG_X86_USER_SHADOW_STACK
> > > +static inline int write_user_shstk_64(u64 __user *addr, u64 val)
> > > +{
> > > + asm_volatile_goto("1: wrussq %[val], (%[addr])\n"
> > > + _ASM_EXTABLE(1b, %l[fail])
> > > + :: [addr] "r" (addr), [val] "r" (val)
> > > + :: fail);
> > > + return 0;
> > > +fail:
> > > + return -EFAULT;
> > > +}
> > > +#endif /* CONFIG_X86_USER_SHADOW_STACK */
> >
> > Why isn't this modelled after put_user() ?
>
> You mean as far as supporting multiple sizes? It just isn't really
> needed yet. We are only writing single frames. I suppose it might make
> more sense with the alt shadow stack support, but that is dropped for
> now.
>
> The other difference here is that WRUSS is a weird instruction that is
> treated as a user access even if it comes from the kernel mode. So it's
> doesn't need to stac/clac.
>
> >
> > Should you write a 64bit value even if the task receiving a signal is
> > 32bit ?
>
> 32 bit support was also dropped.

How? Task could start life as 64bit, frob LDT to set up 32bit code
segment and jump into it and start doing 32bit syscalls, then what?

AFAICT those 32bit syscalls will end up doing SA_IA32_ABI sigframes.