[LTP] [PATCH 1/2] syscalls/prctl02: Fix PR_CAP_AMBIENT testcases

Tudor Cretu tudor.cretu@arm.com
Mon Nov 21 18:30:51 CET 2022


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



More information about the ltp mailing list