[LTP] [PATCH v2 2/2] mseal01: handle more possible errnos when pkey_alloc gets fail
Li Wang
liwang@redhat.com
Tue Aug 6 03:30:38 CEST 2024
On Mon, Aug 5, 2024 at 9:59 PM Petr Vorel <pvorel@suse.cz> wrote:
> Hi Li,
>
> ...
> > static void test_pkey_mprotect(void)
> > {
> > - int ret;
> > int pkey;
>
> > - pkey = tst_syscall(__NR_pkey_alloc, 0, 0);
> > - if (pkey == -1) {
> > - if (errno == EINVAL)
> > - tst_brk(TCONF, "pku is not supported on this CPU");
> > + check_pkey_support();
>
> > - tst_brk(TBROK | TERRNO, "pkey_alloc() error");
> > - }
> > + pkey = ltp_pkey_alloc(0, 0);
> > + if (pkey == -1)
> > + tst_brk(TBROK | TERRNO, "pkey_alloc failed");
>
> > - TST_EXP_FAIL(tst_syscall(__NR_pkey_mprotect,
> > + TST_EXP_FAIL(ltp_pkey_mprotect(
> > mem_addr, mem_size,
> > PROT_NONE,
> > pkey),
> > EPERM);
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> But as I wrote in first patch, I would consider better to rewrite test to
> use
> .test_variants = 2 to test both raw syscall and libc wrapper. That would
> require
>
Sure, as I reply in 1/2 we can delay the work.
> to rewrite the lapi header. And it'd be then safer if pkey01.c would use
> always
> raw syscall variant, no need for not standard "ltp_pkey_mprotect()" name.
>
Good point, I will send a follow-up patch to resolve that.
>
> > - ret = tst_syscall(__NR_pkey_free, pkey);
> > - if (ret == -1)
> > + if (ltp_pkey_free(pkey) == -1)
> > tst_brk(TBROK | TERRNO, "pkey_free() error");
> > }
>
> > @@ -150,7 +147,6 @@ static struct tst_test test = {
> > .test = run,
> > .tcnt = ARRAY_SIZE(tcases),
> > .setup = setup,
> > - .min_kver = "6.10",
> This change would be worth to mention in the changelog.
>
+1
> Kind regards,
> Petr
>
> > .forks_child = 1,
> > };
>
>
--
Regards,
Li Wang
More information about the ltp
mailing list