Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 27, 2020 at 11:56 AM Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:
>
>
>
> > On Aug 27, 2020, at 11:13 AM, Yu, Yu-cheng <yu-cheng.yu@xxxxxxxxx> wrote:
> >
> > On 8/27/2020 6:36 AM, Florian Weimer wrote:
> >> * H. J. Lu:
> >>>> On Thu, Aug 27, 2020 at 6:19 AM Florian Weimer <fweimer@xxxxxxxxxx> wrote:
> >>>>>
> >>>>> * Dave Martin:
> >>>>>
> >>>>>> You're right that this has implications: for i386, libc probably pulls
> >>>>>> more arguments off the stack than are really there in some situations.
> >>>>>> This isn't a new problem though.  There are already generic prctls with
> >>>>>> fewer than 4 args that are used on x86.
> >>>>>
> >>>>> As originally posted, glibc prctl would have to know that it has to pull
> >>>>> an u64 argument off the argument list for ARCH_X86_CET_DISABLE.  But
> >>>>> then the u64 argument is a problem for arch_prctl as well.
> >>>>>
> >>>
> >>> Argument of ARCH_X86_CET_DISABLE is int and passed in register.
> >> The commit message and the C source say otherwise, I think (not sure
> >> about the C source, not a kernel hacker).
> >
> > H.J. Lu suggested that we fix x86 arch_prctl() to take four arguments, and then keep MMAP_SHSTK as an arch_prctl().  Because now the map flags and size are all in registers, this also solves problems being pointed out earlier.  Without a wrapper, the shadow stack mmap call (from user space) will be:
> >
> > syscall(_NR_arch_prctl, ARCH_X86_CET_MMAP_SHSTK, size, MAP_32BIT).
>
> I admit I don’t see a show stopping technical reason we can’t add arguments to an existing syscall, but I’m pretty sure it’s unprecedented, and it doesn’t seem like a good idea.

prctl prototype is:

extern int prctl (int __option, ...)

and implemented in kernel as:

      int prctl(int option, unsigned long arg2, unsigned long arg3,
                 unsigned long arg4, unsigned long arg5);

Not all prctl operations take all 5 arguments.   It also applies
to arch_prctl.  It is quite normal for different operations of
arch_prctl to take different numbers of arguments.

-- 
H.J.




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux