From c5f6863a18976ed448026c6673517e24ffa29fc3 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Mon, 16 May 2016 23:22:11 +0000 Subject: [PATCH] Fix printing of invalid arguments of prctl syscall * prctl.c (SYS_FUNC(prctl)): Print 2nd syscall argument of PR_CAPBSET_DROP, PR_CAPBSET_READ, PR_CAP_AMBIENT, PR_MCE_KILL, and PR_SET_SECCOMP using printxval_long. Print 2nd syscall argument of PR_SET_SECUREBITS using printflags_long. Print 3rd syscall argument of PR_CAP_AMBIENT and PR_MCE_KILL using printxval_long. * tests/prctl-seccomp-strict.c (main): Update. --- prctl.c | 15 ++++++++------- tests/prctl-seccomp-strict.c | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/prctl.c b/prctl.c index 29e00b09..cd51d4c0 100644 --- a/prctl.c +++ b/prctl.c @@ -172,18 +172,19 @@ SYS_FUNC(prctl) case PR_CAPBSET_DROP: case PR_CAPBSET_READ: tprints(", "); - printxval(cap, tcp->u_arg[1], "CAP_???"); + printxval_long(cap, tcp->u_arg[1], "CAP_???"); return RVAL_DECODED; case PR_CAP_AMBIENT: tprints(", "); - printxval(pr_cap_ambient, tcp->u_arg[1], "PR_CAP_AMBIENT_???"); + printxval_long(pr_cap_ambient, tcp->u_arg[1], + "PR_CAP_AMBIENT_???"); switch (tcp->u_arg[1]) { case PR_CAP_AMBIENT_RAISE: case PR_CAP_AMBIENT_LOWER: case PR_CAP_AMBIENT_IS_SET: tprints(", "); - printxval(cap, tcp->u_arg[2], "CAP_???"); + printxval_long(cap, tcp->u_arg[2], "CAP_???"); print_prctl_args(tcp, 3); break; default: @@ -194,10 +195,10 @@ SYS_FUNC(prctl) case PR_MCE_KILL: tprints(", "); - printxval(pr_mce_kill, tcp->u_arg[1], "PR_MCE_KILL_???"); + printxval_long(pr_mce_kill, tcp->u_arg[1], "PR_MCE_KILL_???"); tprints(", "); if (PR_MCE_KILL_SET == tcp->u_arg[1]) - printxval(pr_mce_kill_policy, tcp->u_arg[2], + printxval_long(pr_mce_kill_policy, tcp->u_arg[2], "PR_MCE_KILL_???"); else tprintf("%#lx", tcp->u_arg[2]); @@ -250,7 +251,7 @@ SYS_FUNC(prctl) case PR_SET_SECCOMP: tprints(", "); - printxval(seccomp_mode, tcp->u_arg[1], + printxval_long(seccomp_mode, tcp->u_arg[1], "SECCOMP_MODE_???"); if (SECCOMP_MODE_STRICT == tcp->u_arg[1]) return RVAL_DECODED; @@ -264,7 +265,7 @@ SYS_FUNC(prctl) case PR_SET_SECUREBITS: tprints(", "); - printflags(secbits, tcp->u_arg[1], "SECBIT_???"); + printflags_long(secbits, tcp->u_arg[1], "SECBIT_???"); return RVAL_DECODED; case PR_SET_TIMERSLACK: diff --git a/tests/prctl-seccomp-strict.c b/tests/prctl-seccomp-strict.c index 6ff4bdec..57387c9b 100644 --- a/tests/prctl-seccomp-strict.c +++ b/tests/prctl-seccomp-strict.c @@ -44,8 +44,8 @@ main(void) static const char text2[] = "+++ exited with 0 +++\n"; int rc = prctl(PR_SET_SECCOMP, -1L, 1, 2, 3); - printf("prctl(PR_SET_SECCOMP, %#x /* SECCOMP_MODE_??? */, 0x1, 0x2, 0x3)" - " = %d %s (%m)\n", -1, rc, errno2name()); + printf("prctl(PR_SET_SECCOMP, %#lx /* SECCOMP_MODE_??? */, 0x1, 0x2, 0x3)" + " = %d %s (%m)\n", -1L, rc, errno2name()); fflush(stdout); rc = prctl(PR_SET_SECCOMP, 1); -- 2.40.0