+/*
+ * Copyright (c) 1994-1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl>
+ * Copyright (c) 2005-2007 Roland McGrath <roland@redhat.com>
+ * Copyright (c) 2008-2015 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "defs.h"
#include <sys/prctl.h>
#include "xlat/prctl_options.h"
-#include "xlat/pr_unalign_flags.h"
+#include "xlat/pr_cap_ambient.h"
#include "xlat/pr_mce_kill.h"
#include "xlat/pr_mce_kill_policy.h"
#include "xlat/pr_set_mm.h"
#include "xlat/pr_tsc.h"
+#include "xlat/pr_unalign_flags.h"
#ifndef TASK_COMM_LEN
# define TASK_COMM_LEN 16
SYS_FUNC(prctl)
{
+ const unsigned int option = tcp->u_arg[0];
unsigned int i;
if (entering(tcp))
- printxval(prctl_options, tcp->u_arg[0], "PR_???");
+ printxval(prctl_options, option, "PR_???");
- switch (tcp->u_arg[0]) {
+ switch (option) {
case PR_GET_DUMPABLE:
case PR_GET_KEEPCAPS:
case PR_GET_SECCOMP:
case PR_GET_TIMERSLACK:
case PR_GET_TIMING:
- if (entering(tcp))
- break;
- return syserror(tcp) ? 0 : RVAL_UDECIMAL;
+ return RVAL_DECODED;
case PR_GET_CHILD_SUBREAPER:
case PR_GET_ENDIAN:
break;
if (syserror(tcp) || tcp->u_rval == 0)
return 0;
- tcp->auxstr = sprintflags("", secbits, tcp->u_rval);
+ tcp->auxstr = sprintflags("", secbits,
+ (unsigned long) tcp->u_rval);
return RVAL_STR;
case PR_GET_TID_ADDRESS:
if (entering(tcp))
tprints(", ");
else
- printnum_long(tcp, tcp->u_arg[1], "%#lx");
+ printnum_ptr(tcp, tcp->u_arg[1]);
break;
case PR_GET_TSC:
return RVAL_DECODED;
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_CAPBSET_READ:
- if (entering(tcp)) {
+ case PR_CAP_AMBIENT:
+ tprints(", ");
+ 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[1], "CAP_???");
+ printxval_long(cap, tcp->u_arg[2], "CAP_???");
+ print_prctl_args(tcp, 3);
+ break;
+ default:
+ print_prctl_args(tcp, 2);
break;
}
- return syserror(tcp) ? 0 : RVAL_UDECIMAL;
+ return RVAL_DECODED;
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]);
return RVAL_DECODED;
#ifdef __ANDROID__
-# ifndef PR_SET_VMA
-# define PR_SET_VMA 0x53564d41
-# endif
# ifndef PR_SET_VMA_ANON_NAME
# define PR_SET_VMA_ANON_NAME 0
# endif
case PR_SET_VMA:
if (tcp->u_arg[1] == PR_SET_VMA_ANON_NAME) {
- tprintf(", %lu", tcp->u_arg[1]);
- tprintf(", %#lx", tcp->u_arg[2]);
+ tprintf(", PR_SET_VMA_ANON_NAME, %#lx", tcp->u_arg[2]);
tprintf(", %lu, ", tcp->u_arg[3]);
printstr(tcp, tcp->u_arg[4], -1);
} else {
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;
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:
print_prctl_args(tcp, 2);
return RVAL_DECODED;
- case PR_GET_NO_NEW_PRIVS:
- case PR_GET_THP_DISABLE:
- if (entering(tcp)) {
- print_prctl_args(tcp, 1);
- return 0;
- }
- return syserror(tcp) ? 0 : RVAL_UDECIMAL;
-
case PR_MCE_KILL_GET:
if (entering(tcp)) {
print_prctl_args(tcp, 1);
}
if (syserror(tcp))
return 0;
- tcp->auxstr = xlookup(pr_mce_kill_policy, tcp->u_rval);
+ tcp->auxstr = xlookup(pr_mce_kill_policy,
+ (unsigned long) tcp->u_rval);
return tcp->auxstr ? RVAL_STR : RVAL_UDECIMAL;
+ case PR_GET_NO_NEW_PRIVS:
+ case PR_GET_THP_DISABLE:
case PR_MPX_DISABLE_MANAGEMENT:
case PR_MPX_ENABLE_MANAGEMENT:
default:
SYS_FUNC(arch_prctl)
{
+ const unsigned int option = tcp->u_arg[0];
+
if (entering(tcp))
- printxval(archvals, tcp->u_arg[0], "ARCH_???");
+ printxval(archvals, option, "ARCH_???");
- switch (tcp->u_arg[0]) {
+ switch (option) {
case ARCH_GET_GS:
case ARCH_GET_FS:
if (entering(tcp))
tprints(", ");
else
- printnum_long(tcp, tcp->u_arg[1], "%#lx");
+ printnum_ptr(tcp, tcp->u_arg[1]);
return 0;
}