[LTP] [PATCH 1/1] pkey01: Add .test_variants

Li Wang liwang@redhat.com
Thu Aug 8 09:00:29 CEST 2024


Hi Petr,


Petr Vorel <pvorel@suse.cz> wrote:

not sure if testing libc wrappers makes ATM sense, because (if I read
> glibc code correctly), there is only pkey_mprotect() very thin wrapper
> in sysdeps/unix/sysv/linux/pkey_mprotect.c [1]:
>

Yep, seems pkey_* series wrapper is uncompleted in glibc so far.
I also hesitating to add the variant in LTP test at this moment.

Let's hear other's opinions.

Btw, I additionally add a new test for PKEY_DISABLE_EXECUTE in
separate patch[1], but considering may your patch may be delayed, I
haven't rebase the code from yours.

[1] https://lists.linux.it/pipermail/ltp/2024-August/039719.html



> int
> pkey_mprotect (void *addr, size_t len, int prot, int pkey)
> {
>   if (pkey == -1)
>     /* If the key is -1, the system call is precisely equivalent to
>        mprotect.  */
>     return __mprotect (addr, len, prot);
>   return INLINE_SYSCALL_CALL (pkey_mprotect, addr, len, prot, pkey);
> }
>
> pkey_alloc() and others [2]:
>
>         This adds system call wrappers for pkey_alloc, pkey_free,
> pkey_mprotect,
>         and x86-64 implementations of pkey_get and pkey_set, which
> abstract over
>         the PKRU CPU register and hide the actual number of memory
> protection
>         keys supported by the CPU.  pkey_mprotect with a -1 key is
> implemented
>         using mprotect, so it will work even if the kernel does not
> support the
>         pkey_mprotect system call.
>
>         The system call wrapers use unsigned int instead of unsigned long
> for
>         parameters, so that no special treatment for x32 is needed.  The
> flags
>         argument is currently unused, and the access rights bit mask is
> limited
>         to two bits by the current PKRU register layout anyway.
>
> Besides, something like SYSCALL_VARIANT could be added to
> include/tst_test_macros.h,
>

+1


-- 
Regards,
Li Wang


More information about the ltp mailing list