All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/2] syscalls/prctl: Small fixes and improvements
@ 2022-11-21 17:30 Tudor Cretu
  2022-11-21 17:30 ` [LTP] [PATCH 1/2] syscalls/prctl02: Fix PR_CAP_AMBIENT testcases Tudor Cretu
  2022-11-21 17:30 ` [LTP] [PATCH 2/2] syscalls/prctl: Fix number of arguments Tudor Cretu
  0 siblings, 2 replies; 4+ messages in thread
From: Tudor Cretu @ 2022-11-21 17:30 UTC (permalink / raw)
  To: ltp

A testcase not matches its description and some prctl calls have too
many arguments. I have decided to suggest these small changes to remove
some potential confusion.

Kind regards,
Tudor

Tudor Cretu (2):
  syscalls/prctl02: Fix PR_CAP_AMBIENT testcases
  syscalls/prctl: Fix number of arguments

 testcases/kernel/syscalls/prctl/prctl02.c |  9 ++++++---
 testcases/kernel/syscalls/prctl/prctl07.c | 12 ++++++------
 2 files changed, 12 insertions(+), 9 deletions(-)

-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 1/2] syscalls/prctl02: Fix PR_CAP_AMBIENT testcases
  2022-11-21 17:30 [LTP] [PATCH 0/2] syscalls/prctl: Small fixes and improvements Tudor Cretu
@ 2022-11-21 17:30 ` Tudor Cretu
  2022-11-22  3:06   ` xuyang2018.jy
  2022-11-21 17:30 ` [LTP] [PATCH 2/2] syscalls/prctl: Fix number of arguments Tudor Cretu
  1 sibling, 1 reply; 4+ messages in thread
From: Tudor Cretu @ 2022-11-21 17:30 UTC (permalink / raw)
  To: ltp

Previously, the PR_CAP_AMBIENT testcase that expected EINVAL on nonzero
unused argument (i.e. arg3) was erring because it had an invalid arg2.
In this case, prctl still returns EINVAL, but the testcase description
doesn't match the cause. Fix the description of the testcase and add a
test that properly checks that prctl returns EINVAL on nonzero unused
argument.

Signed-off-by: Tudor Cretu <tudor.cretu@arm.com>
---
 testcases/kernel/syscalls/prctl/prctl02.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/prctl/prctl02.c b/testcases/kernel/syscalls/prctl/prctl02.c
index 81cd8f336..fa9206232 100644
--- a/testcases/kernel/syscalls/prctl/prctl02.c
+++ b/testcases/kernel/syscalls/prctl/prctl02.c
@@ -26,8 +26,9 @@
  * - EINVAL when options is PR_SET_THP_DISABLE & arg3, arg4, arg5 is non-zero.
  * - EINVAL when options is PR_GET_THP_DISABLE & arg2, arg3, arg4, or arg5 is
  *   nonzero
- * - EINVAL when options is PR_CAP_AMBIENT & an unused argument such as arg4
- *   is nonzero
+ * - EINVAL when options is PR_CAP_AMBIENT & arg2 has an invalid value
+ * - EINVAL when options is PR_CAP_AMBIENT & an unused argument such as arg4,
+ *   arg5, or, in the case of PR_CAP_AMBIENT_CLEAR_ALL, arg3 is nonzero
  * - EINVAL when option is PR_GET_SPECULATION_CTRL and unused arguments is
  *   nonzero
  * - EPERM when option is PR_SET_SECUREBITS and the caller does not have the
@@ -69,6 +70,7 @@ static unsigned long bad_addr;
 static unsigned long num_0;
 static unsigned long num_1 = 1;
 static unsigned long num_2 = 2;
+static unsigned long num_PR_CAP_AMBIENT_CLEAR_ALL = PR_CAP_AMBIENT_CLEAR_ALL;
 static unsigned long num_invalid = ULONG_MAX;
 static int seccomp_nsup;
 static int nonewprivs_nsup;
@@ -96,6 +98,7 @@ static struct tcase {
 	{PR_SET_THP_DISABLE, &num_0, &num_1, EINVAL, "PR_SET_THP_DISABLE"},
 	{PR_GET_THP_DISABLE, &num_1, &num_1, EINVAL, "PR_GET_THP_DISABLE"},
 	{PR_CAP_AMBIENT, &num_invalid, &num_0, EINVAL, "PR_CAP_AMBIENT"},
+	{PR_CAP_AMBIENT, &num_PR_CAP_AMBIENT_CLEAR_ALL, &num_1, EINVAL, "PR_CAP_AMBIENT"},
 	{PR_GET_SPECULATION_CTRL, &num_0, &num_invalid, EINVAL, "PR_GET_SPECULATION_CTRL"},
 	{PR_SET_SECUREBITS, &num_0, &num_0, EPERM, "PR_SET_SECUREBITS"},
 	{PR_CAPBSET_DROP, &num_1, &num_0, EPERM, "PR_CAPBSET_DROP"},
-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 2/2] syscalls/prctl: Fix number of arguments
  2022-11-21 17:30 [LTP] [PATCH 0/2] syscalls/prctl: Small fixes and improvements Tudor Cretu
  2022-11-21 17:30 ` [LTP] [PATCH 1/2] syscalls/prctl02: Fix PR_CAP_AMBIENT testcases Tudor Cretu
@ 2022-11-21 17:30 ` Tudor Cretu
  1 sibling, 0 replies; 4+ messages in thread
From: Tudor Cretu @ 2022-11-21 17:30 UTC (permalink / raw)
  To: ltp

prctl accepts maximum five arguments, so remove the sixth argument.

Signed-off-by: Tudor Cretu <tudor.cretu@arm.com>
---
 testcases/kernel/syscalls/prctl/prctl02.c |  2 +-
 testcases/kernel/syscalls/prctl/prctl07.c | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/prctl/prctl02.c b/testcases/kernel/syscalls/prctl/prctl02.c
index fa9206232..b9c36f308 100644
--- a/testcases/kernel/syscalls/prctl/prctl02.c
+++ b/testcases/kernel/syscalls/prctl/prctl02.c
@@ -180,7 +180,7 @@ static void setup(void)
 	if (TST_ERR == EINVAL)
 		thpdisable_nsup = 1;
 
-	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0, 0));
+	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0));
 	if (TST_ERR == EINVAL)
 		capambient_nsup = 1;
 
diff --git a/testcases/kernel/syscalls/prctl/prctl07.c b/testcases/kernel/syscalls/prctl/prctl07.c
index 8b1f32e6f..dd1d2c064 100644
--- a/testcases/kernel/syscalls/prctl/prctl07.c
+++ b/testcases/kernel/syscalls/prctl/prctl07.c
@@ -45,7 +45,7 @@
 
 static inline void check_cap_raise(unsigned int cap, char *message, int fail_flag)
 {
-	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, cap, 0, 0, 0));
+	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, cap, 0, 0));
 	switch (fail_flag) {
 	case 0:
 	if (TST_RET == 0)
@@ -71,7 +71,7 @@ static inline void check_cap_raise(unsigned int cap, char *message, int fail_fla
 
 static inline void check_cap_is_set(unsigned int cap, char *message, int val)
 {
-	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_IS_SET, cap, 0, 0, 0));
+	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_IS_SET, cap, 0, 0));
 	if (TST_RET == 1)
 		tst_res(val ? TPASS : TFAIL,
 			"PR_CAP_AMBIENT_IS_SET %s in AmbientCap", message);
@@ -84,7 +84,7 @@ static inline void check_cap_is_set(unsigned int cap, char *message, int val)
 
 static inline void check_cap_lower(unsigned int cap, char *message)
 {
-	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_LOWER, cap, 0, 0, 0));
+	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_LOWER, cap, 0, 0));
 	if (TST_RET == -1)
 		tst_res(TFAIL | TTERRNO,
 			"PR_CAP_AMBIENT_LOWER %s failed", message);
@@ -139,9 +139,9 @@ static void verify_prctl(void)
 	tst_res(TINFO, "After PR_CAP_AMBIENT_LORWER");
 	TST_ASSERT_FILE_STR(PROC_STATUS, "CapAmb", ZERO_STRING);
 
-	prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, CAP_NET_BIND_SERVICE, 0, 0, 0);
+	prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, CAP_NET_BIND_SERVICE, 0, 0);
 	tst_res(TINFO, "raise cap for clear");
-	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0, 0));
+	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0));
 	if (TST_RET == 0)
 		tst_res(TPASS, "PR_CAP_AMBIENT_CLEAR ALL succeeded");
 	else
@@ -158,7 +158,7 @@ static void verify_prctl(void)
 
 static void setup(void)
 {
-	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0, 0));
+	TEST(prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0));
 	if (TST_RET == 0) {
 		tst_res(TINFO, "kernel supports PR_CAP_AMBIENT");
 		return;
-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/2] syscalls/prctl02: Fix PR_CAP_AMBIENT testcases
  2022-11-21 17:30 ` [LTP] [PATCH 1/2] syscalls/prctl02: Fix PR_CAP_AMBIENT testcases Tudor Cretu
@ 2022-11-22  3:06   ` xuyang2018.jy
  0 siblings, 0 replies; 4+ messages in thread
From: xuyang2018.jy @ 2022-11-22  3:06 UTC (permalink / raw)
  To: Tudor Cretu, ltp

HI Tudor

Good catch, I have merged this patchset.

Best Regards
Yang Xu
> Previously, the PR_CAP_AMBIENT testcase that expected EINVAL on nonzero
> unused argument (i.e. arg3) was erring because it had an invalid arg2.
> In this case, prctl still returns EINVAL, but the testcase description
> doesn't match the cause. Fix the description of the testcase and add a
> test that properly checks that prctl returns EINVAL on nonzero unused
> argument.
> 
> Signed-off-by: Tudor Cretu <tudor.cretu@arm.com>
> ---
>   testcases/kernel/syscalls/prctl/prctl02.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/prctl/prctl02.c b/testcases/kernel/syscalls/prctl/prctl02.c
> index 81cd8f336..fa9206232 100644
> --- a/testcases/kernel/syscalls/prctl/prctl02.c
> +++ b/testcases/kernel/syscalls/prctl/prctl02.c
> @@ -26,8 +26,9 @@
>    * - EINVAL when options is PR_SET_THP_DISABLE & arg3, arg4, arg5 is non-zero.
>    * - EINVAL when options is PR_GET_THP_DISABLE & arg2, arg3, arg4, or arg5 is
>    *   nonzero
> - * - EINVAL when options is PR_CAP_AMBIENT & an unused argument such as arg4
> - *   is nonzero
> + * - EINVAL when options is PR_CAP_AMBIENT & arg2 has an invalid value
> + * - EINVAL when options is PR_CAP_AMBIENT & an unused argument such as arg4,
> + *   arg5, or, in the case of PR_CAP_AMBIENT_CLEAR_ALL, arg3 is nonzero
>    * - EINVAL when option is PR_GET_SPECULATION_CTRL and unused arguments is
>    *   nonzero
>    * - EPERM when option is PR_SET_SECUREBITS and the caller does not have the
> @@ -69,6 +70,7 @@ static unsigned long bad_addr;
>   static unsigned long num_0;
>   static unsigned long num_1 = 1;
>   static unsigned long num_2 = 2;
> +static unsigned long num_PR_CAP_AMBIENT_CLEAR_ALL = PR_CAP_AMBIENT_CLEAR_ALL;
>   static unsigned long num_invalid = ULONG_MAX;
>   static int seccomp_nsup;
>   static int nonewprivs_nsup;
> @@ -96,6 +98,7 @@ static struct tcase {
>   	{PR_SET_THP_DISABLE, &num_0, &num_1, EINVAL, "PR_SET_THP_DISABLE"},
>   	{PR_GET_THP_DISABLE, &num_1, &num_1, EINVAL, "PR_GET_THP_DISABLE"},
>   	{PR_CAP_AMBIENT, &num_invalid, &num_0, EINVAL, "PR_CAP_AMBIENT"},
> +	{PR_CAP_AMBIENT, &num_PR_CAP_AMBIENT_CLEAR_ALL, &num_1, EINVAL, "PR_CAP_AMBIENT"},
>   	{PR_GET_SPECULATION_CTRL, &num_0, &num_invalid, EINVAL, "PR_GET_SPECULATION_CTRL"},
>   	{PR_SET_SECUREBITS, &num_0, &num_0, EPERM, "PR_SET_SECUREBITS"},
>   	{PR_CAPBSET_DROP, &num_1, &num_0, EPERM, "PR_CAPBSET_DROP"},

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-22  3:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21 17:30 [LTP] [PATCH 0/2] syscalls/prctl: Small fixes and improvements Tudor Cretu
2022-11-21 17:30 ` [LTP] [PATCH 1/2] syscalls/prctl02: Fix PR_CAP_AMBIENT testcases Tudor Cretu
2022-11-22  3:06   ` xuyang2018.jy
2022-11-21 17:30 ` [LTP] [PATCH 2/2] syscalls/prctl: Fix number of arguments Tudor Cretu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.