2012-10-13 16:46:48 +07:00
|
|
|
#ifndef _UAPI_LINUX_PTRACE_H
|
|
|
|
#define _UAPI_LINUX_PTRACE_H
|
|
|
|
/* ptrace.h */
|
|
|
|
/* structs and defines to help the user use the ptrace system call. */
|
|
|
|
|
|
|
|
/* has the defines to get at the registers. */
|
|
|
|
|
2013-05-01 05:27:59 +07:00
|
|
|
#include <linux/types.h>
|
2012-10-13 16:46:48 +07:00
|
|
|
|
|
|
|
#define PTRACE_TRACEME 0
|
|
|
|
#define PTRACE_PEEKTEXT 1
|
|
|
|
#define PTRACE_PEEKDATA 2
|
|
|
|
#define PTRACE_PEEKUSR 3
|
|
|
|
#define PTRACE_POKETEXT 4
|
|
|
|
#define PTRACE_POKEDATA 5
|
|
|
|
#define PTRACE_POKEUSR 6
|
|
|
|
#define PTRACE_CONT 7
|
|
|
|
#define PTRACE_KILL 8
|
|
|
|
#define PTRACE_SINGLESTEP 9
|
|
|
|
|
|
|
|
#define PTRACE_ATTACH 16
|
|
|
|
#define PTRACE_DETACH 17
|
|
|
|
|
|
|
|
#define PTRACE_SYSCALL 24
|
|
|
|
|
|
|
|
/* 0x4200-0x4300 are reserved for architecture-independent additions. */
|
|
|
|
#define PTRACE_SETOPTIONS 0x4200
|
|
|
|
#define PTRACE_GETEVENTMSG 0x4201
|
|
|
|
#define PTRACE_GETSIGINFO 0x4202
|
|
|
|
#define PTRACE_SETSIGINFO 0x4203
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic ptrace interface that exports the architecture specific regsets
|
|
|
|
* using the corresponding NT_* types (which are also used in the core dump).
|
|
|
|
* Please note that the NT_PRSTATUS note type in a core dump contains a full
|
|
|
|
* 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the
|
|
|
|
* elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the
|
|
|
|
* other user_regset flavors, the user_regset layout and the ELF core dump note
|
|
|
|
* payload are exactly the same layout.
|
|
|
|
*
|
|
|
|
* This interface usage is as follows:
|
|
|
|
* struct iovec iov = { buf, len};
|
|
|
|
*
|
|
|
|
* ret = ptrace(PTRACE_GETREGSET/PTRACE_SETREGSET, pid, NT_XXX_TYPE, &iov);
|
|
|
|
*
|
|
|
|
* On the successful completion, iov.len will be updated by the kernel,
|
|
|
|
* specifying how much the kernel has written/read to/from the user's iov.buf.
|
|
|
|
*/
|
|
|
|
#define PTRACE_GETREGSET 0x4204
|
|
|
|
#define PTRACE_SETREGSET 0x4205
|
|
|
|
|
|
|
|
#define PTRACE_SEIZE 0x4206
|
|
|
|
#define PTRACE_INTERRUPT 0x4207
|
|
|
|
#define PTRACE_LISTEN 0x4208
|
|
|
|
|
2013-05-01 05:27:59 +07:00
|
|
|
#define PTRACE_PEEKSIGINFO 0x4209
|
|
|
|
|
|
|
|
struct ptrace_peeksiginfo_args {
|
|
|
|
__u64 off; /* from which siginfo to start */
|
|
|
|
__u32 flags;
|
|
|
|
__s32 nr; /* how may siginfos to take */
|
|
|
|
};
|
|
|
|
|
2013-07-04 05:08:12 +07:00
|
|
|
#define PTRACE_GETSIGMASK 0x420a
|
|
|
|
#define PTRACE_SETSIGMASK 0x420b
|
|
|
|
|
2015-10-27 07:23:59 +07:00
|
|
|
#define PTRACE_SECCOMP_GET_FILTER 0x420c
|
|
|
|
|
2013-05-01 05:27:59 +07:00
|
|
|
/* Read signals from a shared (process wide) queue */
|
|
|
|
#define PTRACE_PEEKSIGINFO_SHARED (1 << 0)
|
|
|
|
|
2012-10-13 16:46:48 +07:00
|
|
|
/* Wait extended result codes for the above trace options. */
|
|
|
|
#define PTRACE_EVENT_FORK 1
|
|
|
|
#define PTRACE_EVENT_VFORK 2
|
|
|
|
#define PTRACE_EVENT_CLONE 3
|
|
|
|
#define PTRACE_EVENT_EXEC 4
|
|
|
|
#define PTRACE_EVENT_VFORK_DONE 5
|
|
|
|
#define PTRACE_EVENT_EXIT 6
|
|
|
|
#define PTRACE_EVENT_SECCOMP 7
|
|
|
|
/* Extended result codes which enabled by means other than options. */
|
|
|
|
#define PTRACE_EVENT_STOP 128
|
|
|
|
|
|
|
|
/* Options set using PTRACE_SETOPTIONS or using PTRACE_SEIZE @data param */
|
|
|
|
#define PTRACE_O_TRACESYSGOOD 1
|
|
|
|
#define PTRACE_O_TRACEFORK (1 << PTRACE_EVENT_FORK)
|
|
|
|
#define PTRACE_O_TRACEVFORK (1 << PTRACE_EVENT_VFORK)
|
|
|
|
#define PTRACE_O_TRACECLONE (1 << PTRACE_EVENT_CLONE)
|
|
|
|
#define PTRACE_O_TRACEEXEC (1 << PTRACE_EVENT_EXEC)
|
|
|
|
#define PTRACE_O_TRACEVFORKDONE (1 << PTRACE_EVENT_VFORK_DONE)
|
|
|
|
#define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT)
|
|
|
|
#define PTRACE_O_TRACESECCOMP (1 << PTRACE_EVENT_SECCOMP)
|
|
|
|
|
2012-12-18 07:03:07 +07:00
|
|
|
/* eventless options */
|
seccomp: add ptrace options for suspend/resume
This patch is the first step in enabling checkpoint/restore of processes
with seccomp enabled.
One of the things CRIU does while dumping tasks is inject code into them
via ptrace to collect information that is only available to the process
itself. However, if we are in a seccomp mode where these processes are
prohibited from making these syscalls, then what CRIU does kills the task.
This patch adds a new ptrace option, PTRACE_O_SUSPEND_SECCOMP, that enables
a task from the init user namespace which has CAP_SYS_ADMIN and no seccomp
filters to disable (and re-enable) seccomp filters for another task so that
they can be successfully dumped (and restored). We restrict the set of
processes that can disable seccomp through ptrace because although today
ptrace can be used to bypass seccomp, there is some discussion of closing
this loophole in the future and we would like this patch to not depend on
that behavior and be future proofed for when it is removed.
Note that seccomp can be suspended before any filters are actually
installed; this behavior is useful on criu restore, so that we can suspend
seccomp, restore the filters, unmap our restore code from the restored
process' address space, and then resume the task by detaching and have the
filters resumed as well.
v2 changes:
* require that the tracer have no seccomp filters installed
* drop TIF_NOTSC manipulation from the patch
* change from ptrace command to a ptrace option and use this ptrace option
as the flag to check. This means that as soon as the tracer
detaches/dies, seccomp is re-enabled and as a corrollary that one can not
disable seccomp across PTRACE_ATTACHs.
v3 changes:
* get rid of various #ifdefs everywhere
* report more sensible errors when PTRACE_O_SUSPEND_SECCOMP is incorrectly
used
v4 changes:
* get rid of may_suspend_seccomp() in favor of a capable() check in ptrace
directly
v5 changes:
* check that seccomp is not enabled (or suspended) on the tracer
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Will Drewry <wad@chromium.org>
CC: Roland McGrath <roland@hack.frob.com>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Andy Lutomirski <luto@amacapital.net>
[kees: access seccomp.mode through seccomp_mode() instead]
Signed-off-by: Kees Cook <keescook@chromium.org>
2015-06-13 22:02:48 +07:00
|
|
|
#define PTRACE_O_EXITKILL (1 << 20)
|
|
|
|
#define PTRACE_O_SUSPEND_SECCOMP (1 << 21)
|
2012-12-18 07:03:07 +07:00
|
|
|
|
seccomp: add ptrace options for suspend/resume
This patch is the first step in enabling checkpoint/restore of processes
with seccomp enabled.
One of the things CRIU does while dumping tasks is inject code into them
via ptrace to collect information that is only available to the process
itself. However, if we are in a seccomp mode where these processes are
prohibited from making these syscalls, then what CRIU does kills the task.
This patch adds a new ptrace option, PTRACE_O_SUSPEND_SECCOMP, that enables
a task from the init user namespace which has CAP_SYS_ADMIN and no seccomp
filters to disable (and re-enable) seccomp filters for another task so that
they can be successfully dumped (and restored). We restrict the set of
processes that can disable seccomp through ptrace because although today
ptrace can be used to bypass seccomp, there is some discussion of closing
this loophole in the future and we would like this patch to not depend on
that behavior and be future proofed for when it is removed.
Note that seccomp can be suspended before any filters are actually
installed; this behavior is useful on criu restore, so that we can suspend
seccomp, restore the filters, unmap our restore code from the restored
process' address space, and then resume the task by detaching and have the
filters resumed as well.
v2 changes:
* require that the tracer have no seccomp filters installed
* drop TIF_NOTSC manipulation from the patch
* change from ptrace command to a ptrace option and use this ptrace option
as the flag to check. This means that as soon as the tracer
detaches/dies, seccomp is re-enabled and as a corrollary that one can not
disable seccomp across PTRACE_ATTACHs.
v3 changes:
* get rid of various #ifdefs everywhere
* report more sensible errors when PTRACE_O_SUSPEND_SECCOMP is incorrectly
used
v4 changes:
* get rid of may_suspend_seccomp() in favor of a capable() check in ptrace
directly
v5 changes:
* check that seccomp is not enabled (or suspended) on the tracer
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Will Drewry <wad@chromium.org>
CC: Roland McGrath <roland@hack.frob.com>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Andy Lutomirski <luto@amacapital.net>
[kees: access seccomp.mode through seccomp_mode() instead]
Signed-off-by: Kees Cook <keescook@chromium.org>
2015-06-13 22:02:48 +07:00
|
|
|
#define PTRACE_O_MASK (\
|
|
|
|
0x000000ff | PTRACE_O_EXITKILL | PTRACE_O_SUSPEND_SECCOMP)
|
2012-10-13 16:46:48 +07:00
|
|
|
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _UAPI_LINUX_PTRACE_H */
|