Message ID | 20240803122258.5479-1-liwang@redhat.com |
---|---|
State | Superseded |
Headers | show |
Series | mseal01: handle more possible errnos when pkey_alloc gets fail | expand |
Hi! Thanks for helping on mseal01. I already submitted the patch, but we can apply a new patch on top of it without problems. Review below On 8/3/24 14:22, Li Wang wrote: > Signed-off-by: Li Wang <liwang@redhat.com> > --- > testcases/kernel/syscalls/mseal/mseal01.c | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) > > diff --git a/testcases/kernel/syscalls/mseal/mseal01.c b/testcases/kernel/syscalls/mseal/mseal01.c > index eb2f4d588..2ff6ed119 100644 > --- a/testcases/kernel/syscalls/mseal/mseal01.c > +++ b/testcases/kernel/syscalls/mseal/mseal01.c > @@ -25,6 +25,7 @@ > > #include "tst_test.h" > #include "lapi/syscalls.h" > +#include "../pkeys/pkey.h" The problem with this approach is that testing suites won't be independent anymore. We need to move all pkeys/pkey.h declarations inside the lapi/ folder, in order to use pkey syscalls from any testing suite. > > #define MEMPAGES 8 > #define MEMSEAL 2 > @@ -46,25 +47,19 @@ static void test_mprotect(void) > > 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); > > - TST_EXP_FAIL(tst_syscall(__NR_pkey_mprotect, > + TST_EXP_FAIL(ltp_pkey_mprotect( > mem_addr, mem_size, > PROT_NONE, > pkey), > EPERM); > > - 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 +145,6 @@ static struct tst_test test = { > .test = run, > .tcnt = ARRAY_SIZE(tcases), > .setup = setup, > - .min_kver = "6.10", > .forks_child = 1, > }; > Andrea
On Mon, Aug 5, 2024 at 2:38 PM Andrea Cervesato via ltp <ltp@lists.linux.it> wrote: > Hi! > > Thanks for helping on mseal01. I already submitted the patch, but we can > apply a new patch on top of it without problems. > Review below > > On 8/3/24 14:22, Li Wang wrote: > > Signed-off-by: Li Wang <liwang@redhat.com> > > --- > > testcases/kernel/syscalls/mseal/mseal01.c | 16 +++++----------- > > 1 file changed, 5 insertions(+), 11 deletions(-) > > > > diff --git a/testcases/kernel/syscalls/mseal/mseal01.c > b/testcases/kernel/syscalls/mseal/mseal01.c > > index eb2f4d588..2ff6ed119 100644 > > --- a/testcases/kernel/syscalls/mseal/mseal01.c > > +++ b/testcases/kernel/syscalls/mseal/mseal01.c > > @@ -25,6 +25,7 @@ > > > > #include "tst_test.h" > > #include "lapi/syscalls.h" > > +#include "../pkeys/pkey.h" > The problem with this approach is that testing suites won't be > independent anymore. > We need to move all pkeys/pkey.h declarations inside the lapi/ folder, > in order to use pkey syscalls from any testing suite. > Sure, I will update my patch to include that. Thanks!
diff --git a/testcases/kernel/syscalls/mseal/mseal01.c b/testcases/kernel/syscalls/mseal/mseal01.c index eb2f4d588..2ff6ed119 100644 --- a/testcases/kernel/syscalls/mseal/mseal01.c +++ b/testcases/kernel/syscalls/mseal/mseal01.c @@ -25,6 +25,7 @@ #include "tst_test.h" #include "lapi/syscalls.h" +#include "../pkeys/pkey.h" #define MEMPAGES 8 #define MEMSEAL 2 @@ -46,25 +47,19 @@ static void test_mprotect(void) 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); - TST_EXP_FAIL(tst_syscall(__NR_pkey_mprotect, + TST_EXP_FAIL(ltp_pkey_mprotect( mem_addr, mem_size, PROT_NONE, pkey), EPERM); - 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 +145,6 @@ static struct tst_test test = { .test = run, .tcnt = ARRAY_SIZE(tcases), .setup = setup, - .min_kver = "6.10", .forks_child = 1, };
Signed-off-by: Li Wang <liwang@redhat.com> --- testcases/kernel/syscalls/mseal/mseal01.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)