* [LTP] [PATCH] request_key: Add negative tests for request_key
@ 2024-05-21 8:15 Ma Xinjian via ltp
2024-07-30 10:34 ` Petr Vorel
2024-09-17 8:18 ` Cyril Hrubis
0 siblings, 2 replies; 4+ messages in thread
From: Ma Xinjian via ltp @ 2024-05-21 8:15 UTC (permalink / raw)
To: ltp
Add negative tests for request_key(), when errno is EFAULT or EPERM
Signed-off-by: Ma Xinjian <maxj.fnst@fujitsu.com>
---
runtest/syscalls | 1 +
.../kernel/syscalls/request_key/.gitignore | 1 +
.../syscalls/request_key/request_key06.c | 52 +++++++++++++++++++
3 files changed, 54 insertions(+)
create mode 100644 testcases/kernel/syscalls/request_key/request_key06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 3a28123a5..c04359fcd 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1187,6 +1187,7 @@ request_key02 request_key02
request_key03 request_key03
request_key04 request_key04
request_key05 request_key05
+request_key06 request_key06
rmdir01 rmdir01
rmdir02 rmdir02
diff --git a/testcases/kernel/syscalls/request_key/.gitignore b/testcases/kernel/syscalls/request_key/.gitignore
index e8dc1c570..6dcf613c7 100644
--- a/testcases/kernel/syscalls/request_key/.gitignore
+++ b/testcases/kernel/syscalls/request_key/.gitignore
@@ -3,3 +3,4 @@
/request_key03
/request_key04
/request_key05
+/request_key06
diff --git a/testcases/kernel/syscalls/request_key/request_key06.c b/testcases/kernel/syscalls/request_key/request_key06.c
new file mode 100644
index 000000000..bd872867b
--- /dev/null
+++ b/testcases/kernel/syscalls/request_key/request_key06.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved.
+ * Author: Ma Xinjian <maxj.fnst@fujitsu.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that request_key(2) fails with
+ *
+ * - EFAULT when type points outside the process's accessible address space
+ * - EFAULT when description points outside the process's accessible address space
+ * - EFAULT when callout_info points outside the process's accessible address space
+ * - EPERM when type argument started with a period '.'
+ */
+
+#include "tst_test.h"
+#include "lapi/keyctl.h"
+
+static struct test_case_t {
+ char *type;
+ char *description;
+ char *callout_info;
+ key_serial_t dest_keyring;
+ int expected_errno;
+ char *desc;
+} tcases[] = {
+ {(char *)(-1), "description", NULL, KEY_SPEC_PROCESS_KEYRING, EFAULT,
+ "type points outside the process's accessible address space"},
+ {"type", (char *)(-1), NULL, KEY_SPEC_PROCESS_KEYRING, EFAULT,
+ "description points outside the process's accessible address space"},
+ {"type", "description", (char *)(-1), KEY_SPEC_PROCESS_KEYRING, EFAULT,
+ "callout_info points outside the process's accessible address space"},
+ {".type", "description", NULL, KEY_SPEC_PROCESS_KEYRING, EPERM,
+ "type argument started with a period '.'"},
+};
+
+static void verify_request_key(unsigned int i)
+{
+ struct test_case_t *tc = &tcases[i];
+
+ TST_EXP_FAIL2(request_key(tc->type, tc->description, tc->callout_info,
+ tc->dest_keyring),
+ tc->expected_errno,
+ "%s", tc->desc);
+}
+
+static struct tst_test test = {
+ .tcnt = ARRAY_SIZE(tcases),
+ .test = verify_request_key,
+};
--
2.39.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] request_key: Add negative tests for request_key
2024-05-21 8:15 [LTP] [PATCH] request_key: Add negative tests for request_key Ma Xinjian via ltp
@ 2024-07-30 10:34 ` Petr Vorel
2024-09-17 8:18 ` Cyril Hrubis
2024-09-17 8:18 ` Cyril Hrubis
1 sibling, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2024-07-30 10:34 UTC (permalink / raw)
To: Ma Xinjian; +Cc: keyrings, ltp, Eric Biggers
Hi Ma, Eric, all,
> Add negative tests for request_key(), when errno is EFAULT or EPERM
LGTM, thanks!
Reviewed-by: Petr Vorel <pvorel@suse.cz>
We also somehow test EACCES (request_key04.c). Looking into man page, there are
other interesting errno to test I suppose (EDQUOT, EKEYEXPIRED, EKEYREJECTED,
...)
@Eric, other devs, would you have time to have a quick look on the test?
Kind regards,
Petr
> Signed-off-by: Ma Xinjian <maxj.fnst@fujitsu.com>
> ---
> runtest/syscalls | 1 +
> .../kernel/syscalls/request_key/.gitignore | 1 +
> .../syscalls/request_key/request_key06.c | 52 +++++++++++++++++++
> 3 files changed, 54 insertions(+)
> create mode 100644 testcases/kernel/syscalls/request_key/request_key06.c
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 3a28123a5..c04359fcd 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -1187,6 +1187,7 @@ request_key02 request_key02
> request_key03 request_key03
> request_key04 request_key04
> request_key05 request_key05
> +request_key06 request_key06
> rmdir01 rmdir01
> rmdir02 rmdir02
> diff --git a/testcases/kernel/syscalls/request_key/.gitignore b/testcases/kernel/syscalls/request_key/.gitignore
> index e8dc1c570..6dcf613c7 100644
> --- a/testcases/kernel/syscalls/request_key/.gitignore
> +++ b/testcases/kernel/syscalls/request_key/.gitignore
> @@ -3,3 +3,4 @@
> /request_key03
> /request_key04
> /request_key05
> +/request_key06
> diff --git a/testcases/kernel/syscalls/request_key/request_key06.c b/testcases/kernel/syscalls/request_key/request_key06.c
> new file mode 100644
> index 000000000..bd872867b
> --- /dev/null
> +++ b/testcases/kernel/syscalls/request_key/request_key06.c
> @@ -0,0 +1,52 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved.
> + * Author: Ma Xinjian <maxj.fnst@fujitsu.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * Verify that request_key(2) fails with
> + *
> + * - EFAULT when type points outside the process's accessible address space
> + * - EFAULT when description points outside the process's accessible address space
> + * - EFAULT when callout_info points outside the process's accessible address space
> + * - EPERM when type argument started with a period '.'
> + */
> +
> +#include "tst_test.h"
> +#include "lapi/keyctl.h"
> +
> +static struct test_case_t {
> + char *type;
> + char *description;
> + char *callout_info;
> + key_serial_t dest_keyring;
> + int expected_errno;
> + char *desc;
> +} tcases[] = {
> + {(char *)(-1), "description", NULL, KEY_SPEC_PROCESS_KEYRING, EFAULT,
> + "type points outside the process's accessible address space"},
> + {"type", (char *)(-1), NULL, KEY_SPEC_PROCESS_KEYRING, EFAULT,
> + "description points outside the process's accessible address space"},
> + {"type", "description", (char *)(-1), KEY_SPEC_PROCESS_KEYRING, EFAULT,
> + "callout_info points outside the process's accessible address space"},
> + {".type", "description", NULL, KEY_SPEC_PROCESS_KEYRING, EPERM,
> + "type argument started with a period '.'"},
> +};
> +
> +static void verify_request_key(unsigned int i)
> +{
> + struct test_case_t *tc = &tcases[i];
> +
> + TST_EXP_FAIL2(request_key(tc->type, tc->description, tc->callout_info,
> + tc->dest_keyring),
> + tc->expected_errno,
> + "%s", tc->desc);
> +}
> +
> +static struct tst_test test = {
> + .tcnt = ARRAY_SIZE(tcases),
> + .test = verify_request_key,
> +};
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] request_key: Add negative tests for request_key
2024-07-30 10:34 ` Petr Vorel
@ 2024-09-17 8:18 ` Cyril Hrubis
0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2024-09-17 8:18 UTC (permalink / raw)
To: Petr Vorel; +Cc: keyrings, ltp, Eric Biggers
Hi!
> LGTM, thanks!
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> We also somehow test EACCES (request_key04.c). Looking into man page, there are
> other interesting errno to test I suppose (EDQUOT, EKEYEXPIRED, EKEYREJECTED,
> ...)
>
> @Eric, other devs, would you have time to have a quick look on the test?
I've pushed the patch, we can add more tests later on.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] request_key: Add negative tests for request_key
2024-05-21 8:15 [LTP] [PATCH] request_key: Add negative tests for request_key Ma Xinjian via ltp
2024-07-30 10:34 ` Petr Vorel
@ 2024-09-17 8:18 ` Cyril Hrubis
1 sibling, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2024-09-17 8:18 UTC (permalink / raw)
To: Ma Xinjian; +Cc: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-17 8:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-21 8:15 [LTP] [PATCH] request_key: Add negative tests for request_key Ma Xinjian via ltp
2024-07-30 10:34 ` Petr Vorel
2024-09-17 8:18 ` Cyril Hrubis
2024-09-17 8:18 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox