LCOV - code coverage report
Current view: top level - discof/capture/generated - fd_solcap_tile_seccomp.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 37 0.0 %
Date: 2025-12-28 05:17:03 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* THIS FILE WAS GENERATED BY generate_filters.py. DO NOT EDIT BY HAND! */
       2             : #ifndef HEADER_fd_src_discof_capture_generated_fd_solcap_tile_seccomp_h
       3             : #define HEADER_fd_src_discof_capture_generated_fd_solcap_tile_seccomp_h
       4             : 
       5             : #if defined(__linux__)
       6             : 
       7             : #include "../../../../src/util/fd_util_base.h"
       8             : #include <linux/audit.h>
       9             : #include <linux/capability.h>
      10             : #include <linux/filter.h>
      11             : #include <linux/seccomp.h>
      12             : #include <linux/bpf.h>
      13             : #include <linux/unistd.h>
      14             : #include <sys/syscall.h>
      15             : #include <signal.h>
      16             : #include <stddef.h>
      17             : 
      18             : #if defined(__i386__)
      19             : # define ARCH_NR  AUDIT_ARCH_I386
      20             : #elif defined(__x86_64__)
      21             : # define ARCH_NR  AUDIT_ARCH_X86_64
      22             : #elif defined(__aarch64__)
      23             : # define ARCH_NR AUDIT_ARCH_AARCH64
      24             : #else
      25             : # error "Target architecture is unsupported by seccomp."
      26             : #endif
      27             : static const unsigned int sock_filter_policy_fd_solcap_tile_instr_cnt = 32;
      28             : 
      29           0 : static void populate_sock_filter_policy_fd_solcap_tile( ulong out_cnt, struct sock_filter * out, unsigned int logfile_fd, uint solcap_fd_0, uint solcap_fd_1 ) {
      30           0 :   FD_TEST( out_cnt >= 32 );
      31           0 :   struct sock_filter filter[32] = {
      32             :     /* Check: Jump to RET_KILL_PROCESS if the script's arch != the runtime arch */
      33           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, arch ) ) ),
      34           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ARCH_NR, 0, /* RET_KILL_PROCESS */ 28 ),
      35             :     /* loading syscall number in accumulator */
      36           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) ) ),
      37             :     /* allow write based on expression */
      38           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* check_write */ 4, 0 ),
      39             :     /* allow lseek based on expression */
      40           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_lseek, /* check_lseek */ 11, 0 ),
      41             :     /* allow ftruncate based on expression */
      42           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_ftruncate, /* check_ftruncate */ 14, 0 ),
      43             :     /* allow fsync based on expression */
      44           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 17, 0 ),
      45             :     /* none of the syscalls matched */
      46           0 :     { BPF_JMP | BPF_JA, 0, 0, /* RET_KILL_PROCESS */ 22 },
      47             : //  check_write:
      48             :     /* load syscall argument 0 in accumulator */
      49           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      50           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_ALLOW */ 21, /* lbl_1 */ 0 ),
      51             : //  lbl_1:
      52             :     /* load syscall argument 0 in accumulator */
      53           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      54           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_ALLOW */ 19, /* lbl_2 */ 0 ),
      55             : //  lbl_2:
      56             :     /* load syscall argument 0 in accumulator */
      57           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      58           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, solcap_fd_0, /* RET_ALLOW */ 17, /* lbl_3 */ 0 ),
      59             : //  lbl_3:
      60             :     /* load syscall argument 0 in accumulator */
      61           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      62           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, solcap_fd_1, /* RET_ALLOW */ 15, /* RET_KILL_PROCESS */ 14 ),
      63             : //  check_lseek:
      64             :     /* load syscall argument 0 in accumulator */
      65           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      66           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, solcap_fd_0, /* RET_ALLOW */ 13, /* lbl_4 */ 0 ),
      67             : //  lbl_4:
      68             :     /* load syscall argument 0 in accumulator */
      69           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      70           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, solcap_fd_1, /* RET_ALLOW */ 11, /* RET_KILL_PROCESS */ 10 ),
      71             : //  check_ftruncate:
      72             :     /* load syscall argument 0 in accumulator */
      73           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      74           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, solcap_fd_0, /* RET_ALLOW */ 9, /* lbl_5 */ 0 ),
      75             : //  lbl_5:
      76             :     /* load syscall argument 0 in accumulator */
      77           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      78           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, solcap_fd_1, /* RET_ALLOW */ 7, /* RET_KILL_PROCESS */ 6 ),
      79             : //  check_fsync:
      80             :     /* load syscall argument 0 in accumulator */
      81           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      82           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_ALLOW */ 5, /* lbl_6 */ 0 ),
      83             : //  lbl_6:
      84             :     /* load syscall argument 0 in accumulator */
      85           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      86           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, solcap_fd_0, /* RET_ALLOW */ 3, /* lbl_7 */ 0 ),
      87             : //  lbl_7:
      88             :     /* load syscall argument 0 in accumulator */
      89           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      90           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, solcap_fd_1, /* RET_ALLOW */ 1, /* RET_KILL_PROCESS */ 0 ),
      91             : //  RET_KILL_PROCESS:
      92             :     /* KILL_PROCESS is placed before ALLOW since it's the fallthrough case. */
      93           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      94             : //  RET_ALLOW:
      95             :     /* ALLOW has to be reached by jumping */
      96             :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      97           0 :   };
      98           0 :   fd_memcpy( out, filter, sizeof( filter ) );
      99           0 : }
     100             : 
     101             : #endif /* defined(__linux__) */
     102             : 
     103             : #endif /* HEADER_fd_src_discof_capture_generated_fd_solcap_tile_seccomp_h */

Generated by: LCOV version 1.14