summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2019-01-03 16:04:42 +0100
committerEugene Syromyatnikov <evgsyr@gmail.com>2022-09-02 17:55:13 +0200
commiteef5d244193b0a4998bb8f8d0b3063bc1009dcd5 (patch)
tree9264d48d8562d28f749c4d9c36d9fb453dcfb1fa
parentf8331bb9e3a5ebbe9675aacd9fd21d1ccaf35c33 (diff)
downloadstrace-eef5d244193b0a4998bb8f8d0b3063bc1009dcd5.tar.gz
prctl: print the rest of the arguments for PR_[GS]ET_SPECULATION_CTRL
* prctl.c (SYS_FUNC(prctl)) <case PR_GET_SPECULATION_CTRL, case PR_SET_SPECULATION_CTRL>: Call print_prctl_args for printing the rest of the arguments, since non-zero values there lead to EINVAL.
-rw-r--r--src/prctl.c3
-rw-r--r--tests/prctl-spec-inject.c51
2 files changed, 36 insertions, 18 deletions
diff --git a/src/prctl.c b/src/prctl.c
index 97f42fe15..82d74e881 100644
--- a/src/prctl.c
+++ b/src/prctl.c
@@ -305,6 +305,7 @@ SYS_FUNC(prctl)
if (entering(tcp)) {
tprint_arg_next();
printxval64(pr_spec_cmds, arg2, "PR_SPEC_???");
+ print_prctl_args(tcp, 2);
break;
}
@@ -538,6 +539,8 @@ SYS_FUNC(prctl)
PRINT_VAL_X(arg3);
}
+ print_prctl_args(tcp, 3);
+
return RVAL_DECODED;
case PR_PAC_RESET_KEYS:
diff --git a/tests/prctl-spec-inject.c b/tests/prctl-spec-inject.c
index 4a351a96c..356db1070 100644
--- a/tests/prctl-spec-inject.c
+++ b/tests/prctl-spec-inject.c
@@ -19,10 +19,20 @@
static long injected_val;
+#if SIZEOF_KERNEL_LONG_T > 4
+# define BOGUS_ARG4 ((kernel_ulong_t) 0xdeadfacebadbeefdULL)
+# define BOGUS_ARG5 ((kernel_ulong_t) 0xcafedeadfacefeedULL)
+# define BOGUS_ARGS_STR ", 0xdeadfacebadbeefd, 0xcafedeadfacefeed"
+#else
+# define BOGUS_ARG4 0xfacedbad
+# define BOGUS_ARG5 0xdeadcafe
+# define BOGUS_ARGS_STR ", 0xfacedbad, 0xdeadcafe"
+#endif
+
static long
do_prctl(kernel_ulong_t cmd, kernel_ulong_t arg2, kernel_ulong_t arg3)
{
- long rc = syscall(__NR_prctl, cmd, arg2, arg3);
+ long rc = syscall(__NR_prctl, cmd, arg2, arg3, BOGUS_ARG4, BOGUS_ARG5);
if (rc != injected_val)
error_msg_and_fail("Return value (%ld) differs from expected "
@@ -106,13 +116,15 @@ main(int argc, char **argv)
/* PR_GET_SPECULATION_CTRL */
rc = do_prctl(52, 3, bogus_arg3);
- printf("prctl(PR_GET_SPECULATION_CTRL, 0x3 /* PR_SPEC_??? */) "
- "= %s (INJECTED)\n", sprintrc(rc));
+ printf("prctl(PR_GET_SPECULATION_CTRL, 0x3 /* PR_SPEC_??? */, %#llx"
+ BOGUS_ARGS_STR ") = %s (INJECTED)\n",
+ (unsigned long long) bogus_arg3, sprintrc(rc));
rc = do_prctl(52, bogus_arg2, bogus_arg3);
- printf("prctl(PR_GET_SPECULATION_CTRL, %#llx /* PR_SPEC_??? */) "
- "= %s (INJECTED)\n",
- (unsigned long long) bogus_arg2, sprintrc(rc));
+ printf("prctl(PR_GET_SPECULATION_CTRL, %#llx /* PR_SPEC_??? */, %#llx"
+ BOGUS_ARGS_STR ") = %s (INJECTED)\n",
+ (unsigned long long) bogus_arg2, (unsigned long long) bogus_arg3,
+ sprintrc(rc));
for (unsigned c = 0; c < ARRAY_SIZE(spec_strs); c++) {
rc = do_prctl(52, spec_strs[c].arg, bogus_arg3);
@@ -127,26 +139,29 @@ main(int argc, char **argv)
error_msg_and_fail("Unknown return value: %ld", rc);
if (rc < 0) {
- printf("prctl(PR_GET_SPECULATION_CTRL, %s) = %s%s"
- " (INJECTED)\n",
- spec_strs[c].str, sprintrc(rc), str);
+ printf("prctl(PR_GET_SPECULATION_CTRL, %s, %#llx"
+ BOGUS_ARGS_STR ") = %s%s (INJECTED)\n",
+ spec_strs[c].str,
+ (unsigned long long) bogus_arg3,
+ sprintrc(rc), str);
} else {
- printf("prctl(PR_GET_SPECULATION_CTRL, %s) = %#lx%s"
- " (INJECTED)\n",
- spec_strs[c].str, rc, str);
+ printf("prctl(PR_GET_SPECULATION_CTRL, %s, %#llx"
+ BOGUS_ARGS_STR ") = %#lx%s (INJECTED)\n",
+ spec_strs[c].str,
+ (unsigned long long) bogus_arg3, rc, str);
}
}
/* PR_SET_SPECULATION_CTRL*/
rc = do_prctl(53, 3, bogus_arg3);
- printf("prctl(PR_SET_SPECULATION_CTRL, 0x3 /* PR_SPEC_??? */, %#llx) "
- "= %s (INJECTED)\n",
+ printf("prctl(PR_SET_SPECULATION_CTRL, 0x3 /* PR_SPEC_??? */, %#llx"
+ BOGUS_ARGS_STR ") = %s (INJECTED)\n",
(unsigned long long) bogus_arg3, sprintrc(rc));
rc = do_prctl(53, bogus_arg2, bogus_arg3);
- printf("prctl(PR_SET_SPECULATION_CTRL, %#llx /* PR_SPEC_??? */, %#llx) "
- "= %s (INJECTED)\n",
+ printf("prctl(PR_SET_SPECULATION_CTRL, %#llx /* PR_SPEC_??? */, %#llx"
+ BOGUS_ARGS_STR ") = %s (INJECTED)\n",
(unsigned long long) bogus_arg2,
(unsigned long long) bogus_arg3,
sprintrc(rc));
@@ -154,8 +169,8 @@ main(int argc, char **argv)
for (unsigned c = 0; c < ARRAY_SIZE(spec_strs); c++) {
for (unsigned i = 0; i < ARRAY_SIZE(set_strs); i++) {
rc = do_prctl(53, spec_strs[c].arg, set_strs[i].arg);
- printf("prctl(PR_SET_SPECULATION_CTRL, %s"
- ", %s) = %s (INJECTED)\n",
+ printf("prctl(PR_SET_SPECULATION_CTRL, %s, %s"
+ BOGUS_ARGS_STR ") = %s (INJECTED)\n",
spec_strs[c].str, set_strs[i].str, sprintrc(rc));
}
}