1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 4 * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de) 5 * Copyright (C) 2005 Jeff Dike (jdike@karaya.com) 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 unsigned long offset; 57 long err, child_err; 58 59 int syscall_data_len; 60 /* 128 leaves enough room for additional fields in the struct */ 61 struct stub_syscall syscall_data[(UM_KERN_PAGE_SIZE - 128) / sizeof(struct stub_syscall)] __aligned(16); 62 63 /* data shared with signal handler (only used in seccomp mode) */ 64 short restart_wait; 65 unsigned int futex; 66 int signal; 67 unsigned short si_offset; 68 unsigned short mctx_offset; 69 70 /* seccomp architecture specific state restore */ 71 struct stub_data_arch arch_data; 72 73 /* Stack for our signal handlers and for calling into . */ 74 unsigned char sigstack[UM_KERN_PAGE_SIZE] __aligned(UM_KERN_PAGE_SIZE); 75 }; 76 77 #endif 78