Debian Codegraph @

include/utils/error.h

raw
1 #ifndef ERROR_H
2 #define ERROR_H
3
4 #include "i18n.h"
5
6 #define M_UNSUPPORTED_ARCH _ ("Architecture name %s is not supported")
7 // probe
8 #define M_PROBE_TERMINATED _ ("Found errors when assembling BPF from trace")
9 #define M_REQUEST_TMPFILE_FAILED _ ("Failed to request a temporary file: %s")
10
11 // emu
12 #define M_EMU_TERMINATED \
13 _ ("Found errors when assembling text before emulating")
14 #define M_INPUT_SYS_NR _ ("Please input syscall_nr (syscall name or number)")
15 #define M_INVALID_SYSNR _ ("Invalid syscall_nr")
16
17 // asm
18 #define M_ASM_TERMINATED _ ("Found errors when assembling")
19 #define M_STATEMENT_OVERFLOW _ ("Input file has more than 4096 statements!")
20
21 // disasm
22 #define M_DISASM_TERMINATED _ ("Found fatal errors when disassembling")
23 #define M_NO_FILTER _ ("The input is empty")
24 #define M_TOO_LARGE_INPUT \
25 _ ("The input is larger than 4096 filters! Perhaps inputting a wrong " \
26 "file?")
27 #define M_INPUT_HAS_LEFTOVER \
28 _ ("%u byte(s) at the end of input could not fit into a filter")
29
30 // trace
31 #define M_START_TRACING _ ("Start tracing process %d")
32 #define M_PEEKDATA_FAILED_ADR _ ("Peekdata failed at %p")
33 #define M_EXECV_ERR _ ("Failed to execute new program")
34 #define M_PROCESS_FORK _ ("Process %d spawned a new pid %d")
35 #define M_PROCESS_EXIT _ ("Process %d exited")
36 #define M_PARSE_PID_BPF _ ("Parsing seccomp filter loaded in process %d")
37 #define M_PID_BPF_LOAD_FAIL _ ("Process %d failed to load seccomp filter: %s")
38 #define M_BPF_FAIL_UNKNOWN _ ("Unknown reason")
39 #define M_PROCFS_NOT_ACCESSIBLE _ ("Procfs not accessible, unable to perform")
40 #define M_NOT_AN_CBPF _ ("Found unresolvable non-classic BPF, skipping")
41 #define M_SEIZING_KERNEL_THREAD _ ("Kernel thread can not be seized")
42 #define M_NO_FILTER_FOUND _ ("No seccomp filters found in process %d")
43 #define M_TARGET_TRACED_BY \
44 _ ("Target process is already being traced by process %d")
45 #define M_FOUND_STRICT_MODE \
46 _ ("Process %d loaded strict seccomp mode, which only allows read, " \
47 "write, exit_group and sigreturn!")
48 #define M_UNKNOWN_GETFILTER_ERR _ ("Unknown error when get filter: %s")
49 #define M_UNKNOWN_SEIZE_ERR _ ("Unknown error when seizing process: %s")
50 #define M_SEIZE_NONEXIST_PROC _ ("The process to seize does not exist")
51 // no translation due to terms
52 #define ACTION_GET_FILTER "ptrace get seccomp filters"
53 #define ACTION_PTRACE_SEIZE "ptrace seizing"
54 #define M_TRACE_UNDER_ATTACK \
55 _ ("Unexpected race condition detected when reading seccomp filters, " \
56 "please consider use eBPF-based trace in next version")
57
58 #define M_CAP_SYS_PTRACE_OR_KTHREAD \
59 _ ("perhaps seizing kthread or lacking CAP_SYS_PTRACE")
60 #define M_REQUIRE_CAP_SYS_ADMIN \
61 _ ("Run with CAP_SYS_ADMIN capability to fetch seccomp filters")
62 #define M_REQUIRE_CAP_SYS_PTRACE \
63 _ ("Run with CAP_SYS_PTRACE capability to seize a foreign process")
64 #define M_CANNOT_WORK_FROM_32_TO_64 \
65 _ ("32-bit tracer can not ptrace 64-bit tracee")
66 #define M_TRACEE_ARCH_NOT_SUPPORTED \
67 _ ("libseccomp does not support the tracee's arch (%#x)")
68 #define M_CAP_SYS_ADMIN_OR_IN_SECCOMP \
69 _ ("perhaps lacking CAP_SYS_ADMIN or ceccomp is in seccomp mode")
70 #define M_GET_FILTER_UNSUPPORTED \
71 _ ("PTRACE_GET_SECCOMP_FILTER is not supported on your system")
72 #define M_CECCOMP_IN_SECCOMP \
73 _ ("Ceccomp is in seccomp mode, fetching seccomp filters of other process " \
74 "is not permitted")
75 #define M_GET_FILTER_UNSUPPORTED_OR_NO_FILTER \
76 _ ("perhaps PTRACE_GET_SECCOMP_FILTER is not supported or no seccomp " \
77 "filter in target process")
78
79 // parse_args
80 #define M_INVALID_COLOR_MODE _ ("Invalid color mode")
81 #define M_INVALID_FMT_MODE _ ("Invalid format mode")
82 #define M_INVALID_NUMBER _ ("Invalid number")
83 #define M_UNABLE_OPEN_FILE _ ("Unable to open file %s: %s")
84
85 // read_source
86 #define M_READ_FAIL _ ("Reading input failed: %s")
87 #define M_FOUND_SUS_ZERO \
88 _ ("Found '\\0' at file offset %lu, perhaps it's not a text file?")
89 #define M_FOUND_SUS_NO_LF \
90 _ ("No line break in source file, perhaps it's not a text file?")
91 #define M_FOUND_SUS_LINE \
92 _ ("Line %u has more than %u bytes, perhaps the input is not a text file?")
93 #define M_FILE_TOO_LARGE _ ("The input file is greater than 4 MiB!")
94 #define M_LINES_TOO_MANY \
95 _ ("Found more than 16384 lines of text, perhaps it's not for ceccomp?")
96
97 // hash
98 #define M_CANNOT_FIND_LABEL _ ("Can not find label declaration")
99
100 // parser
101 #define M_UNEXPECT_TOKEN _ ("Unexpected token")
102 #define M_DUPLICATED_LABEL _ ("Found duplicated label declaration")
103 #define M_NUMBER_OVERFLOW _ ("Input number exceeds 32-bit range")
104
105 #define M_EXPECT_OPERATOR _ ("Expect operator")
106 #define M_EXPECT_RIGHT_VAR _ ("Expect rvalue")
107 #define M_EXPECT_RETURN_VAL _ ("Expect return value")
108
109 #define M_EXPECT_NUMBER _ ("Expect number")
110 #define M_EXPECT_PAREN _ ("Expect parenthesis")
111 #define M_EXPECT_BRACKET _ ("Expect bracket")
112 #define M_EXPECT_COMPARTOR _ ("Expect comparator")
113 #define M_EXPECT_LABEL _ ("Expect label")
114 #define M_EXPECT_SYSCALL _ ("Expect valid syscall name")
115 #define M_EXPECT_ARCH \
116 _ ("Architecture token does not match any libseccomp arch, perhaps system " \
117 "libseccomp is too old")
118 // EXPECT_SYSCALL also use in resolver
119
120 #define M_EXPECT_GOTO _ ("Expect 'goto'")
121 #define M_EXPECT_A _ ("Expect '$A'")
122 #define M_EXPECT_ELSE _ ("Expect 'else'")
123
124 // resolver and check_prog
125 #define M_RIGHT_SHOULD_BE_A _ ("Rvalue should be '$A'")
126 #define M_RIGHT_CAN_NOT_BE_A _ ("Rvalue can not be '$A'")
127 #define M_RIGHT_CAN_NOT_BE_X _ ("Rvalue can not be '$X'")
128
129 #define M_RIGHT_SHOULD_BE_A_OR_X _ ("Rvalue should be '$A' or '$X'")
130 #define M_RIGHT_SHOULD_BE_X_OR_NUM _ ("Rvalue should be '$X' or number")
131 #define M_OPERATOR_SHOULD_BE_EQUAL _ ("Operator should be '='")
132 #define M_LEFT_SHOULD_BE_A _ ("Lvalue should be '$A'")
133 #define M_INVALID_ATTR_LOAD \
134 _ ("seccomp_data load offset must be 4-byte aligned")
135 #define M_ATTR_OFFSET_OVERFLOW \
136 _ ("seccomp_data load offset greater than the struct")
137
138 #define M_ARGS_IDX_OUT_OF_RANGE _ ("Args index out of range (0-5)")
139 #define M_MEM_IDX_OUT_OF_RANGE _ ("Mem index out of range (0-15)")
140 #define M_UNINITIALIZED_MEM _ ("Accessing uninitialized mem")
141 #define M_ALU_DIV_BY_ZERO _ ("Dividing by zero")
142 #define M_ALU_SH_OUT_OF_RANGE _ ("Left or right shifting more than 32 bits")
143
144 #define M_RET_DATA_OVERFLOW _ ("Data carried by return motion exceeds 0xffff")
145 #define M_JT_TOO_FAR _ ("JT is larger than 0xff")
146 #define M_JT_MUST_BE_POSITIVE _ ("JT must be positive")
147 #define M_JF_TOO_FAR _ ("JF is larger than 0xff")
148 #define M_JF_MUST_BE_POSITIVE _ ("JF must be positive")
149 #define M_JT_INVALID_TAG _ ("JT out of filters")
150 #define M_JF_INVALID_TAG _ ("JF out of filters")
151 #define M_JA_OUT_OF_FILTERS _ ("JA out of filters")
152 #define M_JA_MUST_BE_POSITIVE _ ("JA must be positive")
153
154 #define M_MUST_END_WITH_RET _ ("BPF filters must end with return")
155 #define M_NO_VALID_CODE _ ("The input does not contain any valid statement")
156
157 #define M_INVALID_OPERATION _ ("Invalid or unknown operation")
158
159 #endif