| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
|
| 4 |
* Copyright (C) 2015 Thomas Meyer ([email protected]) |
| 5 |
* Copyright (C) 2005 Jeff Dike ([email protected]) |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef __STUB_DATA_H |
| 9 |
#define __STUB_DATA_H |
| 10 |
|
| 11 |
#include <linux/compiler_types.h> |
| 12 |
#include <as-layout.h> |
| 13 |
#include <sysdep/tls.h> |
| 14 |
#include <sysdep/stub-data.h> |
| 15 |
#include <mm_id.h> |
| 16 |
|
| 17 |
#define FUTEX_IN_CHILD 0 |
| 18 |
#define FUTEX_IN_KERN 1 |
| 19 |
|
| 20 |
struct stub_init_data { |
| 21 |
int seccomp; |
| 22 |
|
| 23 |
unsigned long stub_start; |
| 24 |
|
| 25 |
int stub_code_fd; |
| 26 |
unsigned long stub_code_offset; |
| 27 |
int stub_data_fd; |
| 28 |
unsigned long stub_data_offset; |
| 29 |
|
| 30 |
unsigned long signal_handler; |
| 31 |
unsigned long signal_restorer; |
| 32 |
}; |
| 33 |
|
| 34 |
#define STUB_NEXT_SYSCALL(s) \ |
| 35 |
((struct stub_syscall *) (((unsigned long) s) + (s)->cmd_len)) |
| 36 |
|
| 37 |
enum stub_syscall_type { |
| 38 |
STUB_SYSCALL_UNSET = 0, |
| 39 |
STUB_SYSCALL_MMAP, |
| 40 |
STUB_SYSCALL_MUNMAP, |
| 41 |
}; |
| 42 |
|
| 43 |
struct stub_syscall { |
| 44 |
struct { |
| 45 |
unsigned long addr; |
| 46 |
unsigned long length; |
| 47 |
unsigned long offset; |
| 48 |
int fd; |
| 49 |
int prot; |
| 50 |
} mem; |
| 51 |
|
| 52 |
enum stub_syscall_type syscall; |
| 53 |
}; |
| 54 |
|
| 55 |
struct stub_data { |
| 56 |
long err; |
| 57 |
|
| 58 |
int syscall_data_len; |
| 59 |
/* 128 leaves enough room for additional fields in the struct */ |
| 60 |
struct stub_syscall syscall_data[(UM_KERN_PAGE_SIZE - 128) / sizeof(struct stub_syscall)] __aligned(16); |
| 61 |
|
| 62 |
/* data shared with signal handler (only used in seccomp mode) */ |
| 63 |
short restart_wait; |
| 64 |
unsigned int futex; |
| 65 |
int signal; |
| 66 |
unsigned short si_offset; |
| 67 |
unsigned short mctx_offset; |
| 68 |
|
| 69 |
/* seccomp architecture specific state restore */ |
| 70 |
struct stub_data_arch arch_data; |
| 71 |
|
| 72 |
/* Stack for our signal handlers and for calling into . */ |
| 73 |
unsigned char sigstack[UM_KERN_PAGE_SIZE] __aligned(UM_KERN_PAGE_SIZE); |
| 74 |
}; |
| 75 |
|
| 76 |
#endif |