On 09-06-2023 10:02, Kevin Brodsky wrote:
On 08/06/2023 13:59, 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"
v2..v3:
- Applied a similar change to io_cancel02.c as well
Review branch: https://git.morello-project.org/tudcre01/morello-linux-ltp/-/commits/morello...
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
.../kernel/syscalls/io_cancel/io_cancel01.c | 18 +++++++++++++++--- .../kernel/syscalls/io_cancel/io_cancel02.c | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/io_cancel/io_cancel01.c b/testcases/kernel/syscalls/io_cancel/io_cancel01.c index f7e8bd061ed7..18c73845cfd3 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) +{
- TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx));
+}
+static void cleanup(void) {
- aio_context_t ctx;
- if (ctx)
TST_EXP_PASS_SILENT(tst_syscall(__NR_io_destroy, ctx));
+}
- memset(&ctx, 0, sizeof(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, };
diff --git a/testcases/kernel/syscalls/io_cancel/io_cancel02.c b/testcases/kernel/syscalls/io_cancel/io_cancel02.c index 92ec65119202..5feb627753e3 100644 --- a/testcases/kernel/syscalls/io_cancel/io_cancel02.c +++ b/testcases/kernel/syscalls/io_cancel/io_cancel02.c @@ -20,10 +20,21 @@ #include <libaio.h> -static void run(void) +static io_context_t ctx;
+static void setup(void) +{
- TST_EXP_PASS_SILENT(io_setup(1, &ctx));
+}
+static void cleanup(void) {
- io_context_t ctx;
- if (ctx)
TST_EXP_PASS_SILENT(io_destroy(ctx));
+} +static void run(void) +{ memset(&ctx, 0, sizeof(ctx));
Surely that memset() needs to be removed too?
Yes... well, this is embarrassing. Thanks! :)
I was going to ask if you got the chance to build LTP against libaio to enable these additional tests, but I suppose this is not the case then :)
I thought about this. I didn't look yet in changing the build to enable dynamic linking. It's on my to-do list though as it will provide some valuable validation. This patch is fairly simple though, so I didn't think it's worth to do it now because I wanted to catch-up with the other series before starting that.
Thanks, Tudor
Kevin
TEST(io_cancel(ctx, NULL, NULL)); @@ -46,6 +57,8 @@ static struct tst_test test = { "CONFIG_AIO=y", NULL },
- .setup = setup,
- .cleanup = cleanup, .test_all = run, };
linux-morello-ltp mailing list -- linux-morello-ltp@op-lists.linaro.org To unsubscribe send an email to linux-morello-ltp-leave@op-lists.linaro.org