seccomp-tools 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +105 -17
  3. data/ext/ptrace/ptrace.c +56 -4
  4. data/lib/seccomp-tools/asm/asm.rb +8 -6
  5. data/lib/seccomp-tools/asm/compiler.rb +130 -224
  6. data/lib/seccomp-tools/asm/sasm.tab.rb +780 -0
  7. data/lib/seccomp-tools/asm/sasm.y +175 -0
  8. data/lib/seccomp-tools/asm/scalar.rb +129 -0
  9. data/lib/seccomp-tools/asm/scanner.rb +163 -0
  10. data/lib/seccomp-tools/asm/statement.rb +32 -0
  11. data/lib/seccomp-tools/asm/token.rb +29 -0
  12. data/lib/seccomp-tools/bpf.rb +31 -7
  13. data/lib/seccomp-tools/cli/asm.rb +3 -3
  14. data/lib/seccomp-tools/cli/base.rb +4 -4
  15. data/lib/seccomp-tools/cli/disasm.rb +27 -3
  16. data/lib/seccomp-tools/cli/dump.rb +4 -2
  17. data/lib/seccomp-tools/cli/emu.rb +1 -4
  18. data/lib/seccomp-tools/const.rb +37 -3
  19. data/lib/seccomp-tools/consts/sys_nr/aarch64.rb +284 -0
  20. data/lib/seccomp-tools/consts/sys_nr/amd64.rb +5 -1
  21. data/lib/seccomp-tools/consts/sys_nr/i386.rb +14 -14
  22. data/lib/seccomp-tools/consts/sys_nr/s390x.rb +365 -0
  23. data/lib/seccomp-tools/disasm/context.rb +2 -2
  24. data/lib/seccomp-tools/disasm/disasm.rb +16 -9
  25. data/lib/seccomp-tools/dumper.rb +12 -3
  26. data/lib/seccomp-tools/emulator.rb +5 -9
  27. data/lib/seccomp-tools/error.rb +31 -0
  28. data/lib/seccomp-tools/instruction/alu.rb +1 -1
  29. data/lib/seccomp-tools/instruction/base.rb +1 -1
  30. data/lib/seccomp-tools/instruction/jmp.rb +28 -10
  31. data/lib/seccomp-tools/instruction/ld.rb +5 -3
  32. data/lib/seccomp-tools/syscall.rb +23 -13
  33. data/lib/seccomp-tools/templates/asm.s390x.asm +26 -0
  34. data/lib/seccomp-tools/util.rb +3 -1
  35. data/lib/seccomp-tools/version.rb +1 -1
  36. metadata +38 -9
  37. data/lib/seccomp-tools/asm/tokenizer.rb +0 -169
@@ -0,0 +1,780 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.4.16
4
+ # from Racc grammar file "".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+
9
+ require 'seccomp-tools/asm/scalar'
10
+ require 'seccomp-tools/asm/scanner'
11
+ require 'seccomp-tools/asm/statement'
12
+
13
+ module SeccompTools
14
+ module Asm
15
+ class SeccompAsmParser < Racc::Parser
16
+
17
+ module_eval(<<'...end sasm.y/module_eval...', 'sasm.y', 136)
18
+ def initialize(scanner)
19
+ @scanner = scanner
20
+ super()
21
+ end
22
+
23
+ # @return [Array<Statement>]
24
+ def parse
25
+ @tokens = @scanner.scan.dup
26
+ return [] if @tokens.empty?
27
+
28
+ @cur_idx = 0
29
+ do_parse
30
+ end
31
+
32
+ def next_token
33
+ token = @tokens[@cur_idx]
34
+ return [false, '$'] if token.nil?
35
+
36
+ @cur_idx += 1
37
+ [token.sym, token.str]
38
+ end
39
+
40
+ def on_error(t, val, vstack)
41
+ raise_error("unexpected string #{last_token.str.inspect}")
42
+ end
43
+
44
+ # @param [String] msg
45
+ # @param [Integer] offset
46
+ # @private
47
+ def raise_error(msg, offset = 0)
48
+ raise SeccompTools::ParseError, @scanner.format_error(last_token(offset), msg)
49
+ end
50
+
51
+ # @param [Integer] off
52
+ # 0 for the last parsed token, -n for the n-th previous parsed token, n for the future n-th token.
53
+ def last_token(off = 0)
54
+ @tokens[@cur_idx - 1 + off]
55
+ end
56
+
57
+ ...end sasm.y/module_eval...
58
+ ##### State transition tables begin ###
59
+
60
+ racc_action_table = [
61
+ 49, 49, 32, 121, 17, 29, 32, 49, 17, 58,
62
+ 25, 35, 106, 35, 35, 40, 45, 42, 50, 49,
63
+ 55, 58, 58, 58, 49, 58, 51, 52, 53, 33,
64
+ 103, 103, 40, 33, 19, 50, 29, 20, 56, 25,
65
+ 58, -55, 35, 51, 52, 53, 6, 12, 40, 40,
66
+ 16, 42, 94, 17, 58, 18, 55, 19, 55, 106,
67
+ 33, 108, 70, 71, 42, 20, 110, 40, 106, 108,
68
+ 58, 19, 50, 73, 74, 75, 77, 78, 79, 20,
69
+ 51, 52, 53, 108, 106, 21, 40, 6, 12, nil,
70
+ nil, 16, nil, nil, 17, nil, 18, nil, 19, nil,
71
+ 6, 12, nil, nil, 16, nil, 20, 17, 50, 18,
72
+ nil, 19, nil, nil, nil, 20, 51, 52, 53, 20,
73
+ 50, nil, 40, 50, nil, nil, nil, nil, 51, 52,
74
+ 53, 51, 52, 53, 40, 50, nil, 40, nil, nil,
75
+ nil, nil, 20, 51, 52, 53, 50, 58, nil, 40,
76
+ nil, nil, nil, 50, 51, 52, 53, nil, nil, nil,
77
+ 40, 51, 52, 53, 50, nil, nil, 40, nil, nil,
78
+ nil, nil, 51, 52, 53, 50, nil, nil, 40, nil,
79
+ nil, nil, 20, 51, 52, 53, nil, 58, nil, 40 ]
80
+
81
+ racc_action_check = [
82
+ 88, 116, 12, 113, 87, 12, 72, 18, 126, 114,
83
+ 2, 13, 114, 14, 15, 16, 18, 17, 18, 37,
84
+ 19, 87, 113, 88, 36, 126, 18, 18, 18, 12,
85
+ 88, 116, 18, 72, 36, 36, 115, 37, 21, 22,
86
+ 24, 30, 31, 36, 36, 36, 26, 26, 45, 36,
87
+ 26, 62, 71, 26, 115, 26, 75, 26, 76, 90,
88
+ 115, 91, 34, 34, 93, 26, 95, 102, 104, 111,
89
+ 26, 34, 34, 34, 34, 34, 34, 34, 34, 34,
90
+ 34, 34, 34, 112, 125, 1, 34, 1, 1, nil,
91
+ nil, 1, nil, nil, 1, nil, 1, nil, 1, nil,
92
+ 0, 0, nil, nil, 0, nil, 1, 0, 28, 0,
93
+ nil, 0, nil, nil, nil, 28, 28, 28, 28, 0,
94
+ 48, nil, 28, 54, nil, nil, nil, nil, 48, 48,
95
+ 48, 54, 54, 54, 48, 61, nil, 54, nil, nil,
96
+ nil, nil, 61, 61, 61, 61, 89, 61, nil, 61,
97
+ nil, nil, nil, 97, 89, 89, 89, nil, nil, nil,
98
+ 89, 97, 97, 97, 98, nil, nil, 97, nil, nil,
99
+ nil, nil, 98, 98, 98, 127, nil, nil, 98, nil,
100
+ nil, nil, 127, 127, 127, 127, nil, 127, nil, 127 ]
101
+
102
+ racc_action_pointer = [
103
+ 98, 85, -15, nil, nil, nil, nil, nil, nil, nil,
104
+ nil, nil, -3, -16, -14, -13, -13, 7, 4, -10,
105
+ nil, 38, 14, nil, 14, nil, 44, nil, 94, nil,
106
+ 14, 15, nil, nil, 58, nil, 21, 16, nil, nil,
107
+ nil, nil, nil, nil, nil, 20, nil, nil, 106, nil,
108
+ nil, nil, nil, nil, 109, nil, nil, nil, nil, nil,
109
+ nil, 121, 41, nil, nil, nil, nil, nil, nil, nil,
110
+ nil, 49, 1, nil, nil, 26, 28, nil, nil, nil,
111
+ nil, nil, nil, nil, nil, nil, nil, -5, -3, 132,
112
+ 30, 30, nil, 54, nil, 52, nil, 139, 150, nil,
113
+ nil, nil, 39, nil, 39, nil, nil, nil, nil, nil,
114
+ nil, 38, 52, -4, -17, 28, -2, nil, nil, nil,
115
+ nil, nil, nil, nil, nil, 55, -1, 161, nil, nil,
116
+ nil ]
117
+
118
+ racc_action_default = [
119
+ -77, -77, -69, -69, -4, -5, -7, -8, -9, -10,
120
+ -11, -12, -60, -77, -77, -77, -77, -77, -77, -77,
121
+ -61, -77, -69, -1, -66, -67, -77, -69, -77, -32,
122
+ -33, -77, -54, -75, -77, -70, -77, -77, -69, -69,
123
+ -71, -34, -35, -36, -37, -38, -40, -56, -77, -60,
124
+ -62, -63, -64, -65, -77, -73, 131, -2, -68, -3,
125
+ -6, -77, -77, -42, -43, -53, -14, -20, -21, -22,
126
+ -23, -77, -44, -46, -47, -77, -77, -50, -51, -52,
127
+ -15, -17, -18, -19, -16, -58, -59, -77, -77, -77,
128
+ -77, -77, -13, -77, -24, -77, -55, -77, -77, -69,
129
+ -69, -69, -77, -76, -77, -57, -72, -41, -74, -26,
130
+ -45, -77, -77, -28, -77, -77, -77, -39, -48, -49,
131
+ -25, -69, -29, -69, -33, -77, -77, -77, -31, -27,
132
+ -30 ]
133
+
134
+ racc_goto_table = [
135
+ 26, 28, 30, 44, 62, 39, 41, 31, 46, 54,
136
+ 67, 99, 100, 23, 1, 14, 14, 69, 105, 82,
137
+ 59, 83, 85, 60, 61, 107, 81, 2, 22, 34,
138
+ 36, 37, 117, 57, 89, 87, 88, 92, 90, 27,
139
+ 125, 14, 122, 66, 91, 118, 119, 65, 80, 84,
140
+ 129, 93, 86, 128, 68, 38, 120, 43, 72, 76,
141
+ nil, nil, 96, nil, nil, 97, 98, 95, nil, nil,
142
+ nil, nil, nil, 101, nil, nil, nil, nil, nil, 104,
143
+ nil, nil, 109, nil, nil, nil, nil, 111, 112, nil,
144
+ nil, 116, nil, nil, nil, nil, 113, 114, 115, nil,
145
+ nil, 101, nil, 130, 123, 124, nil, nil, nil, nil,
146
+ nil, nil, nil, nil, nil, nil, nil, nil, 126, nil,
147
+ 127 ]
148
+
149
+ racc_goto_check = [
150
+ 5, 26, 32, 15, 14, 28, 27, 37, 22, 34,
151
+ 14, 11, 29, 3, 1, 18, 18, 20, 30, 20,
152
+ 6, 15, 15, 7, 5, 35, 22, 2, 2, 16,
153
+ 16, 16, 30, 3, 28, 5, 5, 14, 22, 13,
154
+ 29, 18, 30, 17, 22, 35, 35, 16, 19, 21,
155
+ 11, 27, 18, 30, 23, 24, 25, 33, 36, 38,
156
+ nil, nil, 32, nil, nil, 34, 34, 37, nil, nil,
157
+ nil, nil, nil, 15, nil, nil, nil, nil, nil, 22,
158
+ nil, nil, 27, nil, nil, nil, nil, 22, 22, nil,
159
+ nil, 28, nil, nil, nil, nil, 5, 5, 5, nil,
160
+ nil, 15, nil, 14, 26, 32, nil, nil, nil, nil,
161
+ nil, nil, nil, nil, nil, nil, nil, nil, 5, nil,
162
+ 5 ]
163
+
164
+ racc_goto_pointer = [
165
+ nil, 14, 27, 11, nil, -3, -6, -3, nil, nil,
166
+ nil, -76, nil, 27, -24, -15, 16, 9, 15, 12,
167
+ -17, 12, -10, 20, 39, -57, -11, -11, -11, -76,
168
+ -72, nil, -10, 39, -10, -66, 24, -5, 25, nil ]
169
+
170
+ racc_goto_default = [
171
+ nil, nil, nil, nil, 3, 24, 4, 5, 7, 8,
172
+ 9, 10, 11, nil, nil, 13, nil, nil, 63, nil,
173
+ 15, nil, 64, nil, nil, nil, nil, nil, 48, nil,
174
+ nil, 102, nil, nil, nil, nil, nil, nil, nil, 47 ]
175
+
176
+ racc_reduce_table = [
177
+ 0, 0, :racc_error,
178
+ 2, 35, :_reduce_1,
179
+ 3, 35, :_reduce_2,
180
+ 3, 36, :_reduce_3,
181
+ 1, 36, :_reduce_4,
182
+ 1, 38, :_reduce_5,
183
+ 3, 38, :_reduce_6,
184
+ 1, 41, :_reduce_7,
185
+ 1, 40, :_reduce_8,
186
+ 1, 40, :_reduce_9,
187
+ 1, 40, :_reduce_10,
188
+ 1, 40, :_reduce_11,
189
+ 1, 40, :_reduce_12,
190
+ 4, 42, :_reduce_13,
191
+ 3, 43, :_reduce_14,
192
+ 3, 43, :_reduce_15,
193
+ 3, 43, :_reduce_16,
194
+ 1, 53, :_reduce_none,
195
+ 1, 53, :_reduce_none,
196
+ 1, 53, :_reduce_none,
197
+ 1, 51, :_reduce_none,
198
+ 1, 51, :_reduce_21,
199
+ 1, 51, :_reduce_none,
200
+ 1, 51, :_reduce_23,
201
+ 2, 51, :_reduce_24,
202
+ 6, 44, :_reduce_25,
203
+ 5, 44, :_reduce_26,
204
+ 3, 59, :_reduce_27,
205
+ 0, 59, :_reduce_28,
206
+ 5, 58, :_reduce_29,
207
+ 5, 63, :_reduce_30,
208
+ 4, 63, :_reduce_31,
209
+ 1, 60, :_reduce_none,
210
+ 1, 60, :_reduce_none,
211
+ 2, 45, :_reduce_34,
212
+ 1, 61, :_reduce_35,
213
+ 2, 46, :_reduce_36,
214
+ 1, 67, :_reduce_none,
215
+ 1, 67, :_reduce_38,
216
+ 4, 67, :_reduce_39,
217
+ 1, 67, :_reduce_none,
218
+ 4, 54, :_reduce_41,
219
+ 1, 48, :_reduce_none,
220
+ 1, 48, :_reduce_none,
221
+ 1, 57, :_reduce_none,
222
+ 3, 57, :_reduce_45,
223
+ 1, 57, :_reduce_46,
224
+ 1, 57, :_reduce_47,
225
+ 4, 57, :_reduce_48,
226
+ 4, 70, :_reduce_49,
227
+ 1, 70, :_reduce_50,
228
+ 1, 72, :_reduce_none,
229
+ 1, 72, :_reduce_none,
230
+ 2, 47, :_reduce_53,
231
+ 1, 71, :_reduce_none,
232
+ 1, 71, :_reduce_none,
233
+ 1, 56, :_reduce_56,
234
+ 3, 56, :_reduce_57,
235
+ 1, 55, :_reduce_none,
236
+ 1, 55, :_reduce_none,
237
+ 1, 49, :_reduce_60,
238
+ 1, 52, :_reduce_61,
239
+ 1, 73, :_reduce_62,
240
+ 1, 73, :_reduce_63,
241
+ 1, 73, :_reduce_64,
242
+ 1, 73, :_reduce_65,
243
+ 1, 37, :_reduce_none,
244
+ 1, 37, :_reduce_none,
245
+ 2, 39, :_reduce_none,
246
+ 0, 39, :_reduce_none,
247
+ 1, 50, :_reduce_none,
248
+ 1, 62, :_reduce_none,
249
+ 1, 64, :_reduce_none,
250
+ 1, 68, :_reduce_none,
251
+ 1, 69, :_reduce_none,
252
+ 1, 66, :_reduce_none,
253
+ 1, 65, :_reduce_none ]
254
+
255
+ racc_reduce_n = 77
256
+
257
+ racc_shift_n = 131
258
+
259
+ racc_token_table = {
260
+ false => 0,
261
+ :error => 1,
262
+ :SYMBOL => 2,
263
+ :A => 3,
264
+ :LEN => 4,
265
+ :ALU_OP => 5,
266
+ :IF => 6,
267
+ :ELSE => 7,
268
+ :COMPARE => 8,
269
+ :GOTO => 9,
270
+ :GOTO_SYMBOL => 10,
271
+ :RETURN => 11,
272
+ :ACTION => 12,
273
+ :MEM => 13,
274
+ :INT => 14,
275
+ :SYS_NUMBER => 15,
276
+ :ARCH => 16,
277
+ :DATA => 17,
278
+ :INSTRUCTION_POINTER => 18,
279
+ :ARGS => 19,
280
+ :ARGS_H => 20,
281
+ :X => 21,
282
+ :HEX_INT => 22,
283
+ :ARCH_VAL => 23,
284
+ :SYSCALL => 24,
285
+ :false => 25,
286
+ :NEWLINE => 26,
287
+ "=" => 27,
288
+ "(" => 28,
289
+ ")" => 29,
290
+ "[" => 30,
291
+ "]" => 31,
292
+ "&" => 32,
293
+ "!" => 33 }
294
+
295
+ racc_nt_base = 34
296
+
297
+ racc_use_result_var = false
298
+
299
+ Racc_arg = [
300
+ racc_action_table,
301
+ racc_action_check,
302
+ racc_action_default,
303
+ racc_action_pointer,
304
+ racc_goto_table,
305
+ racc_goto_check,
306
+ racc_goto_default,
307
+ racc_goto_pointer,
308
+ racc_nt_base,
309
+ racc_reduce_table,
310
+ racc_token_table,
311
+ racc_shift_n,
312
+ racc_reduce_n,
313
+ racc_use_result_var ]
314
+
315
+ Racc_token_to_s_table = [
316
+ "$end",
317
+ "error",
318
+ "SYMBOL",
319
+ "A",
320
+ "LEN",
321
+ "ALU_OP",
322
+ "IF",
323
+ "ELSE",
324
+ "COMPARE",
325
+ "GOTO",
326
+ "GOTO_SYMBOL",
327
+ "RETURN",
328
+ "ACTION",
329
+ "MEM",
330
+ "INT",
331
+ "SYS_NUMBER",
332
+ "ARCH",
333
+ "DATA",
334
+ "INSTRUCTION_POINTER",
335
+ "ARGS",
336
+ "ARGS_H",
337
+ "X",
338
+ "HEX_INT",
339
+ "ARCH_VAL",
340
+ "SYSCALL",
341
+ "false",
342
+ "NEWLINE",
343
+ "\"=\"",
344
+ "\"(\"",
345
+ "\")\"",
346
+ "\"[\"",
347
+ "\"]\"",
348
+ "\"&\"",
349
+ "\"!\"",
350
+ "$start",
351
+ "prog",
352
+ "normalized_statement",
353
+ "terminator",
354
+ "symbols",
355
+ "newlines",
356
+ "statement",
357
+ "symbol",
358
+ "arithmetic",
359
+ "assignment",
360
+ "conditional",
361
+ "goto_expr",
362
+ "return_stat",
363
+ "alu_op_eq",
364
+ "x_constexpr",
365
+ "a",
366
+ "ASSIGN",
367
+ "a_rval",
368
+ "x",
369
+ "x_rval",
370
+ "memory",
371
+ "ax",
372
+ "constexpr",
373
+ "argument",
374
+ "comparison",
375
+ "else_block",
376
+ "compare",
377
+ "goto_symbol",
378
+ "LPAREN",
379
+ "comparison_",
380
+ "RPAREN",
381
+ "BANG",
382
+ "AND",
383
+ "ret_val",
384
+ "LBRACK",
385
+ "RBRACK",
386
+ "argument_long",
387
+ "alu_op",
388
+ "args",
389
+ "number" ]
390
+
391
+ Racc_debug_parser = false
392
+
393
+ ##### State transition tables end #####
394
+
395
+ # reduce 0 omitted
396
+
397
+ module_eval(<<'.,.,', 'sasm.y', 3)
398
+ def _reduce_1(val, _values)
399
+ [val[0]]
400
+ end
401
+ .,.,
402
+
403
+ module_eval(<<'.,.,', 'sasm.y', 4)
404
+ def _reduce_2(val, _values)
405
+ val[0] << val[1]
406
+ end
407
+ .,.,
408
+
409
+ module_eval(<<'.,.,', 'sasm.y', 5)
410
+ def _reduce_3(val, _values)
411
+ Statement.new(*val[2], val[0])
412
+ end
413
+ .,.,
414
+
415
+ module_eval(<<'.,.,', 'sasm.y', 6)
416
+ def _reduce_4(val, _values)
417
+ Statement.new(*val[0], [])
418
+ end
419
+ .,.,
420
+
421
+ module_eval(<<'.,.,', 'sasm.y', 7)
422
+ def _reduce_5(val, _values)
423
+ val
424
+ end
425
+ .,.,
426
+
427
+ module_eval(<<'.,.,', 'sasm.y', 8)
428
+ def _reduce_6(val, _values)
429
+ val[0] << val[2]
430
+ end
431
+ .,.,
432
+
433
+ module_eval(<<'.,.,', 'sasm.y', 10)
434
+ def _reduce_7(val, _values)
435
+ t = val[0]
436
+ raise_error("'next' is a reserved label") if t == 'next'
437
+ last_token
438
+
439
+ end
440
+ .,.,
441
+
442
+ module_eval(<<'.,.,', 'sasm.y', 14)
443
+ def _reduce_8(val, _values)
444
+ [:alu, val[0]]
445
+ end
446
+ .,.,
447
+
448
+ module_eval(<<'.,.,', 'sasm.y', 15)
449
+ def _reduce_9(val, _values)
450
+ [:assign, val[0]]
451
+ end
452
+ .,.,
453
+
454
+ module_eval(<<'.,.,', 'sasm.y', 16)
455
+ def _reduce_10(val, _values)
456
+ [:if, val[0]]
457
+ end
458
+ .,.,
459
+
460
+ module_eval(<<'.,.,', 'sasm.y', 17)
461
+ def _reduce_11(val, _values)
462
+ [:if, [nil, val[0], val[0]]]
463
+ end
464
+ .,.,
465
+
466
+ module_eval(<<'.,.,', 'sasm.y', 18)
467
+ def _reduce_12(val, _values)
468
+ [:ret, val[0]]
469
+ end
470
+ .,.,
471
+
472
+ module_eval(<<'.,.,', 'sasm.y', 19)
473
+ def _reduce_13(val, _values)
474
+ [val[1], val[3]]
475
+ end
476
+ .,.,
477
+
478
+ module_eval(<<'.,.,', 'sasm.y', 20)
479
+ def _reduce_14(val, _values)
480
+ [val[0], val[2]]
481
+ end
482
+ .,.,
483
+
484
+ module_eval(<<'.,.,', 'sasm.y', 21)
485
+ def _reduce_15(val, _values)
486
+ [val[0], val[2]]
487
+ end
488
+ .,.,
489
+
490
+ module_eval(<<'.,.,', 'sasm.y', 22)
491
+ def _reduce_16(val, _values)
492
+ [val[0], val[2]]
493
+ end
494
+ .,.,
495
+
496
+ # reduce 17 omitted
497
+
498
+ # reduce 18 omitted
499
+
500
+ # reduce 19 omitted
501
+
502
+ # reduce 20 omitted
503
+
504
+ module_eval(<<'.,.,', 'sasm.y', 29)
505
+ def _reduce_21(val, _values)
506
+ Scalar::Data.new(val[0])
507
+ end
508
+ .,.,
509
+
510
+ # reduce 22 omitted
511
+
512
+ module_eval(<<'.,.,', 'sasm.y', 31)
513
+ def _reduce_23(val, _values)
514
+ Scalar::Len.instance
515
+ end
516
+ .,.,
517
+
518
+ module_eval(<<'.,.,', 'sasm.y', 34)
519
+ def _reduce_24(val, _values)
520
+ raise_error('do you mean A = -A?', -1) if val[0] != '-'
521
+ :neg
522
+
523
+ end
524
+ .,.,
525
+
526
+ module_eval(<<'.,.,', 'sasm.y', 38)
527
+ def _reduce_25(val, _values)
528
+ op, rval, parity = val[1]
529
+ jt, jf = val[3], val[5]
530
+ jt, jf = jf, jt if parity.odd?
531
+ [[op, rval], jt, jf]
532
+
533
+ end
534
+ .,.,
535
+
536
+ module_eval(<<'.,.,', 'sasm.y', 43)
537
+ def _reduce_26(val, _values)
538
+ [[val[1], val[2]], val[3], val[4]]
539
+ end
540
+ .,.,
541
+
542
+ module_eval(<<'.,.,', 'sasm.y', 44)
543
+ def _reduce_27(val, _values)
544
+ val[2]
545
+ end
546
+ .,.,
547
+
548
+ module_eval(<<'.,.,', 'sasm.y', 45)
549
+ def _reduce_28(val, _values)
550
+ :next
551
+ end
552
+ .,.,
553
+
554
+ module_eval(<<'.,.,', 'sasm.y', 46)
555
+ def _reduce_29(val, _values)
556
+ val[2]
557
+ end
558
+ .,.,
559
+
560
+ module_eval(<<'.,.,', 'sasm.y', 47)
561
+ def _reduce_30(val, _values)
562
+ [val[2], val[4], 0]
563
+ end
564
+ .,.,
565
+
566
+ module_eval(<<'.,.,', 'sasm.y', 48)
567
+ def _reduce_31(val, _values)
568
+ val[2][2] += 1; val[2]
569
+ end
570
+ .,.,
571
+
572
+ # reduce 32 omitted
573
+
574
+ # reduce 33 omitted
575
+
576
+ module_eval(<<'.,.,', 'sasm.y', 51)
577
+ def _reduce_34(val, _values)
578
+ val[1]
579
+ end
580
+ .,.,
581
+
582
+ module_eval(<<'.,.,', 'sasm.y', 52)
583
+ def _reduce_35(val, _values)
584
+ last_token
585
+ end
586
+ .,.,
587
+
588
+ module_eval(<<'.,.,', 'sasm.y', 53)
589
+ def _reduce_36(val, _values)
590
+ val[1]
591
+ end
592
+ .,.,
593
+
594
+ # reduce 37 omitted
595
+
596
+ module_eval(<<'.,.,', 'sasm.y', 55)
597
+ def _reduce_38(val, _values)
598
+ Scalar::ConstVal.new(Const::BPF::ACTION[val[0].to_sym])
599
+ end
600
+ .,.,
601
+
602
+ module_eval(<<'.,.,', 'sasm.y', 57)
603
+ def _reduce_39(val, _values)
604
+ Scalar::ConstVal.new(Const::BPF::ACTION[val[0].to_sym] |
605
+ (val[2].to_i & Const::BPF::SECCOMP_RET_DATA))
606
+
607
+ end
608
+ .,.,
609
+
610
+ # reduce 40 omitted
611
+
612
+ module_eval(<<'.,.,', 'sasm.y', 62)
613
+ def _reduce_41(val, _values)
614
+ idx = val[2].to_i
615
+ raise_error(format("index of mem[] must between 0 and 15, got %d", idx), -1) unless idx.between?(0, 15)
616
+ Scalar::Mem.new(idx)
617
+
618
+ end
619
+ .,.,
620
+
621
+ # reduce 42 omitted
622
+
623
+ # reduce 43 omitted
624
+
625
+ # reduce 44 omitted
626
+
627
+ module_eval(<<'.,.,', 'sasm.y', 70)
628
+ def _reduce_45(val, _values)
629
+ if val[1] != '>>' || val[2].to_i != 32
630
+ off = val[1] == '>>' ? 0 : -1
631
+ raise_error("operator after an argument can only be '>> 32'", off)
632
+ end
633
+ val[0] + 4
634
+
635
+ end
636
+ .,.,
637
+
638
+ module_eval(<<'.,.,', 'sasm.y', 76)
639
+ def _reduce_46(val, _values)
640
+ 0
641
+ end
642
+ .,.,
643
+
644
+ module_eval(<<'.,.,', 'sasm.y', 77)
645
+ def _reduce_47(val, _values)
646
+ 4
647
+ end
648
+ .,.,
649
+
650
+ module_eval(<<'.,.,', 'sasm.y', 79)
651
+ def _reduce_48(val, _values)
652
+ idx = val[2].to_i
653
+ if idx % 4 != 0 || idx >= 64
654
+ raise_error(format('index of data[] must be a multiple of 4 and less than 64, got %d', idx), -1)
655
+ end
656
+ idx
657
+
658
+ end
659
+ .,.,
660
+
661
+ module_eval(<<'.,.,', 'sasm.y', 87)
662
+ def _reduce_49(val, _values)
663
+ idx = val[2].to_i
664
+ s = val[0]
665
+ raise_error(format('index of %s[] must between 0 and 5, got %d', s, idx), -1) unless idx.between?(0, 5)
666
+ 16 + idx * 8 + (s.downcase.end_with?('h') ? 4 : 0)
667
+
668
+ end
669
+ .,.,
670
+
671
+ module_eval(<<'.,.,', 'sasm.y', 92)
672
+ def _reduce_50(val, _values)
673
+ 8
674
+ end
675
+ .,.,
676
+
677
+ # reduce 51 omitted
678
+
679
+ # reduce 52 omitted
680
+
681
+ module_eval(<<'.,.,', 'sasm.y', 95)
682
+ def _reduce_53(val, _values)
683
+ val[0] + val[1]
684
+ end
685
+ .,.,
686
+
687
+ # reduce 54 omitted
688
+
689
+ # reduce 55 omitted
690
+
691
+ module_eval(<<'.,.,', 'sasm.y', 98)
692
+ def _reduce_56(val, _values)
693
+ Scalar::ConstVal.new(val[0] & 0xffffffff)
694
+ end
695
+ .,.,
696
+
697
+ module_eval(<<'.,.,', 'sasm.y', 99)
698
+ def _reduce_57(val, _values)
699
+ val[1]
700
+ end
701
+ .,.,
702
+
703
+ # reduce 58 omitted
704
+
705
+ # reduce 59 omitted
706
+
707
+ module_eval(<<'.,.,', 'sasm.y', 102)
708
+ def _reduce_60(val, _values)
709
+ Scalar::A.instance
710
+ end
711
+ .,.,
712
+
713
+ module_eval(<<'.,.,', 'sasm.y', 103)
714
+ def _reduce_61(val, _values)
715
+ Scalar::X.instance
716
+ end
717
+ .,.,
718
+
719
+ module_eval(<<'.,.,', 'sasm.y', 104)
720
+ def _reduce_62(val, _values)
721
+ val[0].to_i
722
+ end
723
+ .,.,
724
+
725
+ module_eval(<<'.,.,', 'sasm.y', 105)
726
+ def _reduce_63(val, _values)
727
+ val[0].to_i(16)
728
+ end
729
+ .,.,
730
+
731
+ module_eval(<<'.,.,', 'sasm.y', 106)
732
+ def _reduce_64(val, _values)
733
+ Const::Audit::ARCH[val[0]]
734
+ end
735
+ .,.,
736
+
737
+ module_eval(<<'.,.,', 'sasm.y', 108)
738
+ def _reduce_65(val, _values)
739
+ s = val[0]
740
+ return @scanner.syscalls[s.to_sym] unless s.include?('.')
741
+
742
+ arch, sys = s.split('.')
743
+ Const::Syscall.const_get(arch.upcase)[sys.to_sym].tap do |v|
744
+ raise_error("syscall '#{sys}' doesn't exist on #{arch}") if v.nil?
745
+ end
746
+
747
+ end
748
+ .,.,
749
+
750
+ # reduce 66 omitted
751
+
752
+ # reduce 67 omitted
753
+
754
+ # reduce 68 omitted
755
+
756
+ # reduce 69 omitted
757
+
758
+ # reduce 70 omitted
759
+
760
+ # reduce 71 omitted
761
+
762
+ # reduce 72 omitted
763
+
764
+ # reduce 73 omitted
765
+
766
+ # reduce 74 omitted
767
+
768
+ # reduce 75 omitted
769
+
770
+ # reduce 76 omitted
771
+
772
+ def _reduce_none(val, _values)
773
+ val[0]
774
+ end
775
+
776
+ end # class SeccompAsmParser
777
+ end # module Asm
778
+ end # module SeccompTools
779
+
780
+