The kernel might check for a valid context before checking the access of the pointers. In such a case, it will return EINVAL instead of EFAULT. Add an io_setup step to the test to ensure the io_cancel syscall fails because of the intended cause.
Signed-off-by: Tudor Cretu tudor.cretu@arm.com --- This patch doesn't have any dependency, but it's a dependency to the following Morello Linux series: "Support aio shared memory usage in the Purecap apps"
Review branch: https://git.morello-project.org/tudcre01/morello-linux-ltp/-/commits/morello... --- .../kernel/syscalls/io_cancel/io_cancel01.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/io_cancel/io_cancel01.c b/testcases/kernel/syscalls/io_cancel/io_cancel01.c index f7e8bd061..31670fbb5 100644 --- a/testcases/kernel/syscalls/io_cancel/io_cancel01.c +++ b/testcases/kernel/syscalls/io_cancel/io_cancel01.c @@ -18,11 +18,21 @@ #include "tst_test.h" #include "lapi/syscalls.h"
-static void run(void) +static aio_context_t ctx; + +static void setup(void) { - aio_context_t ctx; + TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx)); +}
- memset(&ctx, 0, sizeof(ctx)); +static void cleanup(void) +{ + TST_EXP_PASS_SILENT(tst_syscall(__NR_io_destroy, ctx)); +} + + +static void run(void) +{ TST_EXP_FAIL(tst_syscall(__NR_io_cancel, ctx, NULL, NULL), EFAULT); }
@@ -31,5 +41,7 @@ static struct tst_test test = { "CONFIG_AIO=y", NULL }, + .setup = setup, + .cleanup = cleanup, .test_all = run, };
Hi Tudor,
On 05/04/2023 11:19, Tudor Cretu wrote:
The kernel might check for a valid context before checking the access of the pointers. In such a case, it will return EINVAL instead of EFAULT. Add an io_setup step to the test to ensure the io_cancel syscall fails because of the intended cause.
Signed-off-by: Tudor Cretu tudor.cretu@arm.com
This patch doesn't have any dependency, but it's a dependency to the following Morello Linux series: "Support aio shared memory usage in the Purecap apps"
Review branch: https://git.morello-project.org/tudcre01/morello-linux-ltp/-/commits/morello...
.../kernel/syscalls/io_cancel/io_cancel01.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/io_cancel/io_cancel01.c b/testcases/kernel/syscalls/io_cancel/io_cancel01.c index f7e8bd061..31670fbb5 100644 --- a/testcases/kernel/syscalls/io_cancel/io_cancel01.c +++ b/testcases/kernel/syscalls/io_cancel/io_cancel01.c @@ -18,11 +18,21 @@ #include "tst_test.h" #include "lapi/syscalls.h" -static void run(void) +static aio_context_t ctx;
+static void setup(void) {
- aio_context_t ctx;
- TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx));
+}
- memset(&ctx, 0, sizeof(ctx));
+static void cleanup(void) +{
- TST_EXP_PASS_SILENT(tst_syscall(__NR_io_destroy, ctx));
Is this syscall valid if __NR_io_setup has failed ?
My understanding is that if TST_EXP_PASS_SILENT fails for some reason, it will call the cleanup call-back. Maybe there's a way to check with the struct if it has been properly initialized and can be destroyed ?
+}
+static void run(void) +{ TST_EXP_FAIL(tst_syscall(__NR_io_cancel, ctx, NULL, NULL), EFAULT); } @@ -31,5 +41,7 @@ static struct tst_test test = { "CONFIG_AIO=y", NULL },
- .setup = setup,
- .cleanup = cleanup, .test_all = run, };
Other than my small comment the patch looks good to me !
(Sadly it will have to wait for Beata's return to be merged as I cannot push patches)
Best regards, Téo
On 18-04-2023 11:35, Teo Couprie Diaz wrote:
Hi Tudor,
On 05/04/2023 11:19, Tudor Cretu wrote:
The kernel might check for a valid context before checking the access of the pointers. In such a case, it will return EINVAL instead of EFAULT. Add an io_setup step to the test to ensure the io_cancel syscall fails because of the intended cause.
Signed-off-by: Tudor Cretu tudor.cretu@arm.com
This patch doesn't have any dependency, but it's a dependency to the following Morello Linux series: "Support aio shared memory usage in the Purecap apps"
Review branch: https://git.morello-project.org/tudcre01/morello-linux-ltp/-/commits/morello...
.../kernel/syscalls/io_cancel/io_cancel01.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/io_cancel/io_cancel01.c b/testcases/kernel/syscalls/io_cancel/io_cancel01.c index f7e8bd061..31670fbb5 100644 --- a/testcases/kernel/syscalls/io_cancel/io_cancel01.c +++ b/testcases/kernel/syscalls/io_cancel/io_cancel01.c @@ -18,11 +18,21 @@ #include "tst_test.h" #include "lapi/syscalls.h" -static void run(void) +static aio_context_t ctx;
+static void setup(void) { - aio_context_t ctx; + TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx)); +} - memset(&ctx, 0, sizeof(ctx)); +static void cleanup(void) +{ + TST_EXP_PASS_SILENT(tst_syscall(__NR_io_destroy, ctx));
Is this syscall valid if __NR_io_setup has failed ?
My understanding is that if TST_EXP_PASS_SILENT fails for some reason, it will call the cleanup call-back.
That's correct.
Maybe there's a way to check with the struct if it has been properly initialized and can be destroyed ?
I added the setup and cleanup similarly to the test io_submit02.c. I can add the check though, sure.
+}
+static void run(void) +{ TST_EXP_FAIL(tst_syscall(__NR_io_cancel, ctx, NULL, NULL), EFAULT); } @@ -31,5 +41,7 @@ static struct tst_test test = { "CONFIG_AIO=y", NULL }, + .setup = setup, + .cleanup = cleanup, .test_all = run, };
Other than my small comment the patch looks good to me !
(Sadly it will have to wait for Beata's return to be merged as I cannot push patches)
Thanks for the review!
Tudor
Best regards, Téo
linux-morello-ltp@op-lists.linaro.org