summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2021-08-17 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2021-08-17 08:00:00 +0000
commit23244e2d5b53c322907bc65a8af73b6bbd2a9c2d (patch)
treef3ebe19bbbfd391000d1d41735d559956e996c42
parenta67ddcf0d980cbe791874ead41535497dd591d3b (diff)
downloadstrace-23244e2d5b53c322907bc65a8af73b6bbd2a9c2d.tar.gz
tests: use prctl_marker
* tests/prctl-arg2-intptr.c (main): Use prctl_marker. * tests/prctl-cap-ambient.c: Likewise. * tests/prctl-capbset.c: Likewise. * tests/prctl-dumpable.c: Likewise. * tests/prctl-fp-mode.c: Likewise. * tests/prctl-mce-kill.c: Likewise. * tests/prctl-name.c: Likewise. * tests/prctl-no-args.c: Likewise. * tests/prctl-pac-enabled-keys.c: Likewise. * tests/prctl-pac-reset-keys.c: Likewise. * tests/prctl-pdeathsig.c: Likewise. * tests/prctl-seccomp-filter-v.c: Likewise. * tests/prctl-seccomp-strict.c: Likewise. * tests/prctl-securebits.c: Likewise. * tests/prctl-spec-inject.c: Likewise. * tests/prctl-sve.c: Likewise. * tests/prctl-syscall-user-dispatch.c: Likewise. * tests/prctl-tagged-addr.c: Likewise. * tests/prctl-tid_address.c: Likewise. * tests/prctl-tsc.c: Likewise. * tests/prctl-unalign.c: Likewise.
-rw-r--r--tests/prctl-arg2-intptr.c3
-rw-r--r--tests/prctl-cap-ambient.c5
-rw-r--r--tests/prctl-capbset.c5
-rw-r--r--tests/prctl-dumpable.c7
-rw-r--r--tests/prctl-fp-mode.c6
-rw-r--r--tests/prctl-mce-kill.c5
-rw-r--r--tests/prctl-name.c5
-rw-r--r--tests/prctl-no-args.c7
-rw-r--r--tests/prctl-pac-enabled-keys.c9
-rw-r--r--tests/prctl-pac-reset-keys.c4
-rw-r--r--tests/prctl-pdeathsig.c6
-rw-r--r--tests/prctl-seccomp-filter-v.c3
-rw-r--r--tests/prctl-seccomp-strict.c6
-rw-r--r--tests/prctl-securebits.c9
-rw-r--r--tests/prctl-spec-inject.c6
-rw-r--r--tests/prctl-sve.c5
-rw-r--r--tests/prctl-syscall-user-dispatch.c5
-rw-r--r--tests/prctl-tagged-addr.c9
-rw-r--r--tests/prctl-tid_address.c6
-rw-r--r--tests/prctl-tsc.c6
-rw-r--r--tests/prctl-unalign.c6
21 files changed, 38 insertions, 85 deletions
diff --git a/tests/prctl-arg2-intptr.c b/tests/prctl-arg2-intptr.c
index 2b197e155..e0d863a64 100644
--- a/tests/prctl-arg2-intptr.c
+++ b/tests/prctl-arg2-intptr.c
@@ -53,8 +53,7 @@ main(void)
long rc;
unsigned int i;
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
+ prctl_marker();
for (i = 0; i < ARRAY_SIZE(options); ++i) {
prctl(options[i].val | bogus_op_bits, 0);
diff --git a/tests/prctl-cap-ambient.c b/tests/prctl-cap-ambient.c
index f06bd8719..81e52b9ef 100644
--- a/tests/prctl-cap-ambient.c
+++ b/tests/prctl-cap-ambient.c
@@ -17,11 +17,10 @@
int
main(void)
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
long rc;
+ prctl_marker();
+
rc = syscall(__NR_prctl, PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE,
CAP_NET_RAW, 0, 0);
printf("prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, CAP_NET_RAW, 0, 0) = %s\n",
diff --git a/tests/prctl-capbset.c b/tests/prctl-capbset.c
index a7384e213..49975779f 100644
--- a/tests/prctl-capbset.c
+++ b/tests/prctl-capbset.c
@@ -17,11 +17,10 @@
int
main(void)
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
long rc;
+ prctl_marker();
+
rc = syscall(__NR_prctl, PR_CAPBSET_READ, CAP_AUDIT_CONTROL);
printf("prctl(PR_CAPBSET_READ, CAP_AUDIT_CONTROL) = %s\n",
sprintrc(rc));
diff --git a/tests/prctl-dumpable.c b/tests/prctl-dumpable.c
index 083b8d4d4..8aca09817 100644
--- a/tests/prctl-dumpable.c
+++ b/tests/prctl-dumpable.c
@@ -33,9 +33,6 @@ prctl(kernel_ulong_t arg1, kernel_ulong_t arg2)
int
main(void)
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
static const kernel_ulong_t bogus_dumpable1 =
(kernel_ulong_t) 0xdeadc0de00000001ULL;
static const kernel_ulong_t bogus_dumpable2 =
@@ -47,7 +44,7 @@ main(void)
"SUID_DUMP_ROOT",
};
- unsigned int i;
+ prctl_marker();
prctl(PR_SET_DUMPABLE, 3);
printf("prctl(PR_SET_DUMPABLE, 0x3 /* SUID_DUMP_??? */) = %s\n",
@@ -66,7 +63,7 @@ main(void)
printf("prctl(PR_SET_DUMPABLE, %#llx /* SUID_DUMP_??? */) = %s\n",
(unsigned long long) bogus_dumpable2, errstr);
- for (i = 0; i < ARRAY_SIZE(args); ++i) {
+ for (unsigned int i = 0; i < ARRAY_SIZE(args); ++i) {
prctl(PR_SET_DUMPABLE, i);
printf("prctl(PR_SET_DUMPABLE, %s) = %s\n", args[i], errstr);
diff --git a/tests/prctl-fp-mode.c b/tests/prctl-fp-mode.c
index 6ec60dde0..8a52bd3cd 100644
--- a/tests/prctl-fp-mode.c
+++ b/tests/prctl-fp-mode.c
@@ -74,11 +74,7 @@ main(int argc, char **argv)
injected_val = strtol(argv[2], NULL, 0);
for (size_t i = 0; i < num_skip; i++) {
- long ret = syscall(__NR_prctl, -1U, (unsigned long) -2U,
- (unsigned long) -3U, (unsigned long) -4U,
- (unsigned long) -5U);
-
- if ((ret != injected_val) ||
+ if ((prctl_marker() != injected_val) ||
((injected_val == -1) && (errno != ENOTTY)))
continue;
diff --git a/tests/prctl-mce-kill.c b/tests/prctl-mce-kill.c
index 5df480f1b..23ea3cea6 100644
--- a/tests/prctl-mce-kill.c
+++ b/tests/prctl-mce-kill.c
@@ -16,11 +16,10 @@
int
main(void)
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
long rc;
+ prctl_marker();
+
rc = syscall(__NR_prctl, PR_MCE_KILL, PR_MCE_KILL_CLEAR, 0, 0, 0);
printf("prctl(PR_MCE_KILL, PR_MCE_KILL_CLEAR, 0, 0, 0) = %s\n",
sprintrc(rc));
diff --git a/tests/prctl-name.c b/tests/prctl-name.c
index 9e4fb7b46..10a4a49a9 100644
--- a/tests/prctl-name.c
+++ b/tests/prctl-name.c
@@ -19,15 +19,14 @@
int
main(void)
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
static const char str[] = "0123456789abcdef";
static const int len = sizeof(str) - 1;
char *name = tail_memdup(str, sizeof(str));
int i;
int rc;
+ prctl_marker();
+
rc = prctl(PR_SET_NAME, NULL);
printf("prctl(PR_SET_NAME, NULL) = %s\n", sprintrc(rc));
diff --git a/tests/prctl-no-args.c b/tests/prctl-no-args.c
index a4793efe0..78325fd1c 100644
--- a/tests/prctl-no-args.c
+++ b/tests/prctl-no-args.c
@@ -39,12 +39,9 @@ main(void)
TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, ptr);
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
+ prctl_marker();
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(options); i++) {
+ for (unsigned int i = 0; i < ARRAY_SIZE(options); i++) {
long rc = syscall(__NR_prctl, options[i].val | bogus_op_bits,
bogus_arg);
printf("prctl(%s) = %s\n", options[i].str, sprintrc(rc));
diff --git a/tests/prctl-pac-enabled-keys.c b/tests/prctl-pac-enabled-keys.c
index 3f93cc777..544ae47fc 100644
--- a/tests/prctl-pac-enabled-keys.c
+++ b/tests/prctl-pac-enabled-keys.c
@@ -29,8 +29,7 @@
int
main(int argc, char *argv[])
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
+ prctl_marker();
#ifdef INJECT_RETVAL
unsigned long num_skip;
@@ -44,11 +43,7 @@ main(int argc, char *argv[])
inject_retval = strtol(argv[2], NULL, 0);
for (size_t i = 0; i < num_skip; i++) {
- long ret = syscall(__NR_prctl, -1U, (unsigned long) -2U,
- (unsigned long) -3U, (unsigned long) -4U,
- (unsigned long) -5U);
-
- if (ret != inject_retval)
+ if (prctl_marker() != inject_retval)
continue;
locked = true;
diff --git a/tests/prctl-pac-reset-keys.c b/tests/prctl-pac-reset-keys.c
index 9935be361..64d23286e 100644
--- a/tests/prctl-pac-reset-keys.c
+++ b/tests/prctl-pac-reset-keys.c
@@ -17,11 +17,9 @@
int
main(void)
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
long rc;
+ prctl_marker();
rc = syscall(__NR_prctl, PR_PAC_RESET_KEYS, 0x20, 0, 0, 0);
if (rc >= 0) {
diff --git a/tests/prctl-pdeathsig.c b/tests/prctl-pdeathsig.c
index 644d85037..54a9453b9 100644
--- a/tests/prctl-pdeathsig.c
+++ b/tests/prctl-pdeathsig.c
@@ -23,12 +23,10 @@ main(void)
(kernel_ulong_t) 0xbadc0deddeadfeedULL;
TAIL_ALLOC_OBJECT_CONST_PTR(int, pdeathsig);
-
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
long rc;
+ prctl_marker();
+
rc = syscall(__NR_prctl, PR_SET_PDEATHSIG, bogus_signal);
printf("prctl(PR_SET_PDEATHSIG, %llu) = %s\n",
(unsigned long long) bogus_signal, sprintrc(rc));
diff --git a/tests/prctl-seccomp-filter-v.c b/tests/prctl-seccomp-filter-v.c
index 76e0ad26a..563a6a16b 100644
--- a/tests/prctl-seccomp-filter-v.c
+++ b/tests/prctl-seccomp-filter-v.c
@@ -68,8 +68,7 @@ main(void)
{
int fds[2];
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
+ prctl_marker();
puts("prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) = 0");
diff --git a/tests/prctl-seccomp-strict.c b/tests/prctl-seccomp-strict.c
index e2e005b02..65408f856 100644
--- a/tests/prctl-seccomp-strict.c
+++ b/tests/prctl-seccomp-strict.c
@@ -18,11 +18,11 @@ main(void)
static const char text1[] =
"prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT) = 0\n";
static const char text2[] = "+++ exited with 0 +++\n";
+ int rc;
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
+ prctl_marker();
- int rc = prctl(PR_SET_SECCOMP, -1L, 1, 2, 3);
+ rc = prctl(PR_SET_SECCOMP, -1L, 1, 2, 3);
printf("prctl(PR_SET_SECCOMP, %#lx /* SECCOMP_MODE_??? */, 0x1, 0x2, 0x3)"
" = %d %s (%m)\n", -1L, rc, errno2name());
fflush(stdout);
diff --git a/tests/prctl-securebits.c b/tests/prctl-securebits.c
index 8e4eaf1d6..be0c42969 100644
--- a/tests/prctl-securebits.c
+++ b/tests/prctl-securebits.c
@@ -41,8 +41,7 @@ prctl(kernel_ulong_t arg1, kernel_ulong_t arg2)
int
main(int argc, char *argv[])
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
+ prctl_marker();
#ifdef INJECT_RETVAL
unsigned long num_skip;
@@ -54,11 +53,7 @@ main(int argc, char *argv[])
num_skip = strtoul(argv[1], NULL, 0);
for (size_t i = 0; i < num_skip; i++) {
- long ret = syscall(__NR_prctl, -1U, (unsigned long) -2U,
- (unsigned long) -3U, (unsigned long) -4U,
- (unsigned long) -5U);
-
- if (ret < 0)
+ if (prctl_marker() < 0)
continue;
locked = true;
diff --git a/tests/prctl-spec-inject.c b/tests/prctl-spec-inject.c
index 455ce2f31..598467f4d 100644
--- a/tests/prctl-spec-inject.c
+++ b/tests/prctl-spec-inject.c
@@ -91,11 +91,7 @@ main(int argc, char **argv)
injected_val = strtol(argv[2], NULL, 0);
for (size_t i = 0; i < num_skip; i++) {
- long ret = syscall(__NR_prctl, -1U, (unsigned long) -2U,
- (unsigned long) -3U, (unsigned long) -4U,
- (unsigned long) -5U);
-
- if ((ret != injected_val) ||
+ if ((prctl_marker() != injected_val) ||
((injected_val == -1) && (errno != ENOTTY)))
continue;
diff --git a/tests/prctl-sve.c b/tests/prctl-sve.c
index f2b741161..4cef149cf 100644
--- a/tests/prctl-sve.c
+++ b/tests/prctl-sve.c
@@ -16,11 +16,10 @@
int
main(void)
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
long rc;
+ prctl_marker();
+
rc = syscall(__NR_prctl, PR_SVE_SET_VL, 0xf);
printf("prctl(PR_SVE_SET_VL, %#lx) = %s\n", (unsigned long) 0xf,
sprintrc(rc));
diff --git a/tests/prctl-syscall-user-dispatch.c b/tests/prctl-syscall-user-dispatch.c
index fac321b25..1959368ca 100644
--- a/tests/prctl-syscall-user-dispatch.c
+++ b/tests/prctl-syscall-user-dispatch.c
@@ -17,11 +17,10 @@
int
main(void)
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
long rc;
+ prctl_marker();
+
rc = syscall(__NR_prctl, PR_SET_SYSCALL_USER_DISPATCH,
PR_SYS_DISPATCH_ON,
(kernel_ulong_t) 0xdeadbeeffacefeedULL, 0, 0);
diff --git a/tests/prctl-tagged-addr.c b/tests/prctl-tagged-addr.c
index 4cca83e71..24e0f6a23 100644
--- a/tests/prctl-tagged-addr.c
+++ b/tests/prctl-tagged-addr.c
@@ -57,8 +57,7 @@ print_tagged_addr_arg(kernel_ulong_t arg)
int
main(int argc, char *argv[])
{
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
+ prctl_marker();
#ifdef INJECT_RETVAL
unsigned long num_skip;
@@ -72,11 +71,7 @@ main(int argc, char *argv[])
inject_retval = strtol(argv[2], NULL, 0);
for (size_t i = 0; i < num_skip; i++) {
- long ret = syscall(__NR_prctl, -1U, (unsigned long) -2U,
- (unsigned long) -3U, (unsigned long) -4U,
- (unsigned long) -5U);
-
- if (ret != inject_retval)
+ if (prctl_marker() != inject_retval)
continue;
locked = true;
diff --git a/tests/prctl-tid_address.c b/tests/prctl-tid_address.c
index 74e5d681e..8b9460759 100644
--- a/tests/prctl-tid_address.c
+++ b/tests/prctl-tid_address.c
@@ -38,13 +38,11 @@ main(void)
/* Note that kernel puts kernel-sized pointer even on x32 */
TAIL_ALLOC_OBJECT_CONST_PTR(kernel_ulong_t, ptr);
-
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
long rc;
long set_ok;
+ prctl_marker();
+
*ptr = (kernel_ulong_t) 0xbadc0dedda7a1057ULL;
rc = syscall(__NR_prctl, PR_GET_TID_ADDRESS, NULL);
diff --git a/tests/prctl-tsc.c b/tests/prctl-tsc.c
index a6fac8065..6e65829b7 100644
--- a/tests/prctl-tsc.c
+++ b/tests/prctl-tsc.c
@@ -22,12 +22,10 @@ main(void)
(kernel_ulong_t) 0xdeadc0defacebeefULL;
TAIL_ALLOC_OBJECT_CONST_PTR(int, tsc);
-
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
long rc;
+ prctl_marker();
+
rc = syscall(__NR_prctl, PR_SET_TSC, 0);
printf("prctl(PR_SET_TSC, 0 /* PR_TSC_??? */) = %s\n", sprintrc(rc));
diff --git a/tests/prctl-unalign.c b/tests/prctl-unalign.c
index 4710f6c91..eed0cf7d0 100644
--- a/tests/prctl-unalign.c
+++ b/tests/prctl-unalign.c
@@ -17,12 +17,10 @@ int
main(void)
{
TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, unalign);
-
- syscall(__NR_prctl, -1U, (unsigned long) -2U, (unsigned long) -3U,
- (unsigned long) -4U, (unsigned long) -5U);
-
long rc;
+ prctl_marker();
+
rc = syscall(__NR_prctl, PR_SET_UNALIGN, PR_UNALIGN_NOPRINT | PR_UNALIGN_SIGBUS);
printf("prctl(PR_SET_UNALIGN, PR_UNALIGN_NOPRINT|PR_UNALIGN_SIGBUS) = %s\n",
sprintrc(rc));