Skip to content

Commit

Permalink
pkey01: Fix TBROK due missing results
Browse files Browse the repository at this point in the history
PKEY_DISABLE_EXECUTE is ppc64le specific test. Due messages being
TINFO test on other archs fails:

    tst_test.c:1498: TBROK: Test 2 haven't reported results!

Changing messages to TCONF. Also exit loop on !execute_supported TCONF
(no need to have 30x TCONF with the same error message, because we have
PKEY_DISABLE_EXECUTE last). The other TCONF (on MAP_HUGETLB) must be
repeated.

Link: https://lore.kernel.org/ltp/[email protected]/
Fixes: d2b8a47 ("pkey01: Adding test for PKEY_DISABLE_EXECUTE")
Reviewed-by: Li Wang <[email protected]>
Signed-off-by: Petr Vorel <[email protected]>
  • Loading branch information
pevik committed Aug 9, 2024
1 parent 6e13426 commit cc410ea
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions testcases/kernel/syscalls/pkeys/pkey01.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static struct tcase {
} tcases[] = {
{PERM_NAME(PKEY_DISABLE_ACCESS)},
{PERM_NAME(PKEY_DISABLE_WRITE)},
{PERM_NAME(PKEY_DISABLE_EXECUTE)},
{PERM_NAME(PKEY_DISABLE_EXECUTE)} /* keep it the last */
};

static void setup(void)
Expand Down Expand Up @@ -155,7 +155,11 @@ static size_t function_size(void (*func)(void))
return (size_t)(end - start + 1);
}

static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
/*
* return: 1 if it's safe to quit testing on failure (all following would be
* TCONF, O otherwise.
*/
static int pkey_test(struct tcase *tc, struct mmap_param *mpa)
{
pid_t pid;
char *buffer;
Expand All @@ -165,13 +169,13 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
size_t func_size = 0;

if (!execute_supported && (tc->access_rights == PKEY_DISABLE_EXECUTE)) {
tst_res(TINFO, "skip PKEY_DISABLE_EXECUTE test");
return;
tst_res(TCONF, "skip PKEY_DISABLE_EXECUTE test");
return 1;
}

if (!tst_hugepages && (mpa->flags & MAP_HUGETLB)) {
tst_res(TINFO, "Skip test on (%s) buffer", flag_to_str(mpa->flags));
return;
tst_res(TCONF, "Skip test on (%s) buffer", flag_to_str(mpa->flags));
return 0;
}

if (fd == 0)
Expand Down Expand Up @@ -253,6 +257,8 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)

if (pkey_free(pkey) == -1)
tst_brk(TBROK | TERRNO, "pkey_free failed");

return 0;
}

static void verify_pkey(unsigned int i)
Expand All @@ -265,7 +271,8 @@ static void verify_pkey(unsigned int i)
for (j = 0; j < ARRAY_SIZE(mmap_params); j++) {
mpa = &mmap_params[j];

pkey_test(tc, mpa);
if (pkey_test(tc, mpa))
break;
}
}

Expand Down

0 comments on commit cc410ea

Please sign in to comment.