2016-10-31 15:06:48 +03:00
|
|
|
#ifndef UAPI_COMPEL_PTRACE_H__
|
|
|
|
#define UAPI_COMPEL_PTRACE_H__
|
2011-12-19 21:57:59 +04:00
|
|
|
|
2017-02-08 06:36:10 -08:00
|
|
|
/*
|
|
|
|
* We'd want to include both sys/ptrace.h and linux/ptrace.h,
|
|
|
|
* hoping that most definitions come from either one or another.
|
|
|
|
* Alas, on Alpine/musl both files declare struct ptrace_peeksiginfo_args,
|
|
|
|
* so there is no way they can be used together. Let's rely on libc one.
|
|
|
|
*/
|
2011-12-19 21:57:59 +04:00
|
|
|
#include <sys/ptrace.h>
|
2018-05-07 11:42:41 +03:00
|
|
|
#include <stdint.h>
|
2011-12-19 21:57:59 +04:00
|
|
|
|
2016-10-31 15:06:48 +03:00
|
|
|
#include <compel/asm/breakpoints.h>
|
2016-10-27 11:26:55 +03:00
|
|
|
|
2017-02-08 06:36:10 -08:00
|
|
|
/*
|
|
|
|
* Some constants for ptrace that might be missing from the
|
|
|
|
* standard library includes due to being (relatively) new.
|
|
|
|
*/
|
|
|
|
|
2011-12-19 23:18:17 +04:00
|
|
|
#ifndef PTRACE_SEIZE
|
|
|
|
# define PTRACE_SEIZE 0x4206
|
|
|
|
#endif
|
|
|
|
|
2015-06-18 11:59:16 -06:00
|
|
|
#ifndef PTRACE_O_SUSPEND_SECCOMP
|
|
|
|
# define PTRACE_O_SUSPEND_SECCOMP (1 << 21)
|
|
|
|
#endif
|
|
|
|
|
2011-12-19 23:18:17 +04:00
|
|
|
#ifndef PTRACE_INTERRUPT
|
|
|
|
# define PTRACE_INTERRUPT 0x4207
|
|
|
|
#endif
|
|
|
|
|
2013-03-25 23:39:48 +04:00
|
|
|
#ifndef PTRACE_PEEKSIGINFO
|
|
|
|
#define PTRACE_PEEKSIGINFO 0x4209
|
2014-02-03 18:40:00 +04:00
|
|
|
|
|
|
|
/* Read signals from a shared (process wide) queue */
|
|
|
|
#define PTRACE_PEEKSIGINFO_SHARED (1 << 0)
|
|
|
|
#endif
|
|
|
|
|
2013-10-11 10:47:58 +04:00
|
|
|
#ifndef PTRACE_GETREGSET
|
|
|
|
# define PTRACE_GETREGSET 0x4204
|
|
|
|
# define PTRACE_SETREGSET 0x4205
|
|
|
|
#endif
|
2013-03-25 23:39:48 +04:00
|
|
|
|
2016-02-24 14:04:00 +03:00
|
|
|
#ifndef PTRACE_GETSIGMASK
|
|
|
|
# define PTRACE_GETSIGMASK 0x420a
|
|
|
|
# define PTRACE_SETSIGMASK 0x420b
|
|
|
|
#endif
|
2013-07-11 13:46:49 +04:00
|
|
|
|
2015-11-16 22:17:45 -07:00
|
|
|
#ifndef PTRACE_SECCOMP_GET_FILTER
|
|
|
|
#define PTRACE_SECCOMP_GET_FILTER 0x420c
|
|
|
|
#endif
|
|
|
|
|
2018-05-07 11:42:41 +03:00
|
|
|
#ifndef PTRACE_SECCOMP_GET_METADATA
|
|
|
|
# define PTRACE_SECCOMP_GET_METADATA 0x420d
|
2018-05-22 23:21:01 +03:00
|
|
|
#endif /* PTRACE_SECCOMP_GET_METADATA */
|
2018-05-07 11:42:41 +03:00
|
|
|
|
2018-05-22 23:21:01 +03:00
|
|
|
/*
|
|
|
|
* struct seccomp_metadata is not yet
|
|
|
|
* settled down well in headers so use
|
|
|
|
* own identical definition for a while.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
2018-05-07 11:42:41 +03:00
|
|
|
uint64_t filter_off; /* Input: which filter */
|
|
|
|
uint64_t flags; /* Output: filter's flags */
|
2018-05-22 23:21:01 +03:00
|
|
|
} seccomp_metadata_t;
|
2018-05-07 11:42:41 +03:00
|
|
|
|
2017-02-08 06:36:10 -08:00
|
|
|
#ifdef PTRACE_EVENT_STOP
|
|
|
|
# if PTRACE_EVENT_STOP == 7 /* Bad value from Linux 3.1-3.3, fixed in 3.4 */
|
|
|
|
# undef PTRACE_EVENT_STOP
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
#ifndef PTRACE_EVENT_STOP
|
|
|
|
# define PTRACE_EVENT_STOP 128
|
|
|
|
#endif
|
2011-12-19 21:57:59 +04:00
|
|
|
|
2017-02-08 06:36:10 -08:00
|
|
|
extern int ptrace_suspend_seccomp(pid_t pid);
|
2016-10-27 11:26:55 +03:00
|
|
|
|
2017-03-16 15:45:39 +03:00
|
|
|
extern int ptrace_peek_area(pid_t pid, void *dst, void *addr, long bytes);
|
|
|
|
extern int ptrace_poke_area(pid_t pid, void *src, void *addr, long bytes);
|
|
|
|
extern int ptrace_swap_area(pid_t pid, void *dst, void *src, long bytes);
|
|
|
|
|
2016-10-31 15:06:48 +03:00
|
|
|
#endif /* UAPI_COMPEL_PTRACE_H__ */
|