LCOV - code coverage report
Current view: top level - disco/diag/generated - fd_diag_tile_seccomp.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 61 0.0 %
Date: 2026-10-22 18:10:43 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_disco_diag_generated_fd_diag_tile_seccomp_h
       3             : #define HEADER_fd_src_disco_diag_generated_fd_diag_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             : #elif defined(__riscv) && __riscv_xlen == 64
      25             : # define ARCH_NR AUDIT_ARCH_RISCV64
      26             : #else
      27             : # error "Target architecture is unsupported by seccomp."
      28             : #endif
      29             : 
      30             : #define FD_SECCOMP_ARG_LO_OFFSET(argno) ( offsetof( struct seccomp_data, args[(argno)] ) )
      31             : #define FD_SECCOMP_ARG_HI_OFFSET(argno) ( offsetof( struct seccomp_data, args[(argno)] ) + 4U )
      32             : 
      33             : #define FD_SECCOMP_ARG_LO(x) ((uint)(((ulong)(uint)(int)(x)      ) & 0xffffffffUL))
      34             : #define FD_SECCOMP_ARG_HI(x) ((uint)(((ulong)(x) >> 32) & 0xffffffffUL))
      35             : 
      36             : static const uint sock_filter_policy_fd_diag_tile_instr_cnt = 55;
      37             : 
      38           0 : static void populate_sock_filter_policy_fd_diag_tile( ulong out_cnt, struct sock_filter out[ static 55 ], uint logfile_fd ) {
      39           0 :   FD_TEST( out_cnt >= 55 );
      40           0 :   struct sock_filter filter[55] = {
      41             :     /* validate architecture */
      42           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, arch ) )),
      43           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ARCH_NR, 0, /* RET_KILL_PROCESS */ 9 ),
      44             :     /* load syscall number */
      45           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) )),
      46             :     /* check write */
      47           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* check_write */ 9, 0 ),
      48             :     /* check fsync */
      49           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 14, 0 ),
      50             :     /* check lseek */
      51           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_lseek, /* check_lseek */ 17, 0 ),
      52             :     /* check read */
      53           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_read, /* check_read */ 28, 0 ),
      54             :     /* check fstat */
      55           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fstat, /* check_fstat */ 33, 0 ),
      56             :     /* check fstatfs */
      57           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fstatfs, /* check_fstatfs */ 36, 0 ),
      58             :     /* check futex */
      59           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_futex, /* check_futex */ 39, 0 ),
      60             :     /* allow restart_syscall */
      61           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_restart_syscall, /* RET_ALLOW */ 1, 0 ),
      62             : //  RET_KILL_PROCESS:
      63             :     /* default deny */
      64           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      65             : //  RET_ALLOW:
      66             :     /* allow */
      67           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      68             : //  check_write:
      69             :     /* arg 0 low 32 bits */
      70           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      71           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 3, /* or_1 */ 0 ),
      72             : //  or_1:
      73             :     /* arg 0 low 32 bits */
      74           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      75           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
      76             : //  write_KILL:
      77           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      78             : //  write_ALLOW:
      79           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      80             : //  check_fsync:
      81             :     /* arg 0 low 32 bits */
      82           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      83           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
      84             : //  fsync_KILL:
      85           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      86             : //  fsync_ALLOW:
      87           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      88             : //  check_lseek:
      89             :     /* arg 0 low 32 bits */
      90           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      91           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* lseek_KILL */ 8, /* or_3 */ 0 ),
      92             : //  or_3:
      93             :     /* arg 0 low 32 bits */
      94           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      95           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* lseek_KILL */ 6, /* and_2 */ 0 ),
      96             : //  and_2:
      97             :     /* arg 1 high 32 bits */
      98           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(1)),
      99           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_5 */ 0, /* lseek_KILL */ 4 ),
     100             : //  arg_hi_eq_5:
     101             :     /* arg 1 low 32 bits */
     102           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
     103           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_4 */ 0, /* lseek_KILL */ 2 ),
     104             : //  and_4:
     105             :     /* arg 2 low 32 bits */
     106           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
     107           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(SEEK_SET), /* lseek_ALLOW */ 1, /* lseek_KILL */ 0 ),
     108             : //  lseek_KILL:
     109           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     110             : //  lseek_ALLOW:
     111           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     112             : //  check_read:
     113             :     /* arg 0 low 32 bits */
     114           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     115           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* read_KILL */ 2, /* or_6 */ 0 ),
     116             : //  or_6:
     117             :     /* arg 0 low 32 bits */
     118           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     119           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* read_KILL */ 0, /* read_ALLOW */ 1 ),
     120             : //  read_KILL:
     121           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     122             : //  read_ALLOW:
     123           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     124             : //  check_fstat:
     125             :     /* arg 0 low 32 bits */
     126           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     127           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* fstat_KILL */ 0, /* fstat_ALLOW */ 1 ),
     128             : //  fstat_KILL:
     129           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     130             : //  fstat_ALLOW:
     131           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     132             : //  check_fstatfs:
     133             :     /* arg 0 low 32 bits */
     134           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     135           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* fstatfs_KILL */ 0, /* fstatfs_ALLOW */ 1 ),
     136             : //  fstatfs_KILL:
     137           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     138             : //  fstatfs_ALLOW:
     139           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     140             : //  check_futex:
     141             :     /* arg 1 low 32 bits */
     142           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
     143           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(FUTEX_WAIT_BITSET), /* and_7 */ 0, /* futex_KILL */ 2 ),
     144             : //  and_7:
     145             :     /* arg 2 low 32 bits */
     146           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
     147           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* futex_ALLOW */ 1, /* futex_KILL */ 0 ),
     148             : //  futex_KILL:
     149           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     150             : //  futex_ALLOW:
     151           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     152           0 :   };
     153           0 :   fd_memcpy( out, filter, sizeof( filter ) );
     154           0 : }
     155             : 
     156             : #endif /* defined(__linux__) */
     157             : 
     158             : #endif /* HEADER_fd_src_disco_diag_generated_fd_diag_tile_seccomp_h */

Generated by: LCOV version 1.14