LCOV - code coverage report
Current view: top level - discof/failover/generated - fd_failover_tile_seccomp.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 69 0.0 %
Date: 2026-11-11 12:40:43 Functions: 0 2 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_failover_generated_fd_failover_tile_seccomp_h
       3             : #define HEADER_fd_src_discof_failover_generated_fd_failover_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_failover_tile_instr_cnt = 63;
      37             : 
      38           0 : static void populate_sock_filter_policy_fd_failover_tile( ulong out_cnt, struct sock_filter out[ static 63 ], uint logfile_fd, uint listen_fd ) {
      39           0 :   FD_TEST( out_cnt >= 63 );
      40           0 :   struct sock_filter filter[63] = {
      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 */ 13 ),
      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 */ 13, 0 ),
      48             :     /* check fsync */
      49           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 18, 0 ),
      50             :     /* check futex */
      51           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_futex, /* check_futex */ 21, 0 ),
      52             :     /* allow restart_syscall */
      53           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_restart_syscall, /* RET_ALLOW */ 9, 0 ),
      54             :     /* allow getrandom */
      55           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_getrandom, /* RET_ALLOW */ 8, 0 ),
      56             :     /* check socket */
      57           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_socket, /* check_socket */ 24, 0 ),
      58             :     /* allow connect */
      59           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_connect, /* RET_ALLOW */ 6, 0 ),
      60             :     /* check setsockopt */
      61           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_setsockopt, /* check_setsockopt */ 30, 0 ),
      62             :     /* check accept4 */
      63           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_accept4, /* check_accept4 */ 37, 0 ),
      64             :     /* allow recvfrom */
      65           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_recvfrom, /* RET_ALLOW */ 3, 0 ),
      66             :     /* allow sendto */
      67           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* RET_ALLOW */ 2, 0 ),
      68             :     /* check close */
      69           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_close, /* check_close */ 40, 0 ),
      70             : //  RET_KILL_PROCESS:
      71             :     /* default deny */
      72           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      73             : //  RET_ALLOW:
      74             :     /* allow */
      75           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      76             : //  check_write:
      77             :     /* arg 0 low 32 bits */
      78           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      79           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 3, /* or_1 */ 0 ),
      80             : //  or_1:
      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)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
      84             : //  write_KILL:
      85           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      86             : //  write_ALLOW:
      87           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      88             : //  check_fsync:
      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, ((uint)(logfile_fd)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
      92             : //  fsync_KILL:
      93           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      94             : //  fsync_ALLOW:
      95           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      96             : //  check_futex:
      97             :     /* arg 1 low 32 bits */
      98           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
      99           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(FUTEX_WAIT_BITSET), /* and_2 */ 0, /* futex_KILL */ 2 ),
     100             : //  and_2:
     101             :     /* arg 2 low 32 bits */
     102           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
     103           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* futex_ALLOW */ 1, /* futex_KILL */ 0 ),
     104             : //  futex_KILL:
     105           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     106             : //  futex_ALLOW:
     107           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     108             : //  check_socket:
     109             :     /* arg 0 low 32 bits */
     110           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     111           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(AF_INET), /* and_3 */ 0, /* socket_KILL */ 4 ),
     112             : //  and_3:
     113             :     /* arg 1 low 32 bits */
     114           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
     115           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC), /* and_4 */ 0, /* socket_KILL */ 2 ),
     116             : //  and_4:
     117             :     /* arg 2 low 32 bits */
     118           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
     119           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* socket_ALLOW */ 1, /* socket_KILL */ 0 ),
     120             : //  socket_KILL:
     121           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     122             : //  socket_ALLOW:
     123           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     124             : //  check_setsockopt:
     125             :     /* arg 1 low 32 bits */
     126           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
     127           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(IPPROTO_TCP), /* and_5 */ 0, /* setsockopt_KILL */ 4 ),
     128             : //  and_5:
     129             :     /* arg 2 low 32 bits */
     130           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
     131           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(TCP_NODELAY), /* setsockopt_ALLOW */ 3, /* or_6 */ 0 ),
     132             : //  or_6:
     133             :     /* arg 2 low 32 bits */
     134           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
     135           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(TCP_DEFER_ACCEPT), /* setsockopt_ALLOW */ 1, /* setsockopt_KILL */ 0 ),
     136             : //  setsockopt_KILL:
     137           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     138             : //  setsockopt_ALLOW:
     139           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     140             : //  check_accept4:
     141             :     /* arg 0 low 32 bits */
     142           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     143           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(listen_fd)), /* and_7 */ 0, /* accept4_KILL */ 2 ),
     144             : //  and_7:
     145             :     /* arg 3 low 32 bits */
     146           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
     147           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(SOCK_NONBLOCK|SOCK_CLOEXEC), /* accept4_ALLOW */ 1, /* accept4_KILL */ 0 ),
     148             : //  accept4_KILL:
     149           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     150             : //  accept4_ALLOW:
     151           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     152             : //  check_close:
     153             :     /* arg 0 low 32 bits */
     154           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     155           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* close_KILL */ 4, /* or_8 */ 0 ),
     156             : //  or_8:
     157             :     /* arg 0 low 32 bits */
     158           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     159           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* close_KILL */ 2, /* or_9 */ 0 ),
     160             : //  or_9:
     161             :     /* arg 0 low 32 bits */
     162           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     163           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(listen_fd)), /* close_KILL */ 0, /* close_ALLOW */ 1 ),
     164             : //  close_KILL:
     165           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     166             : //  close_ALLOW:
     167           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     168           0 :   };
     169           0 :   fd_memcpy( out, filter, sizeof( filter ) );
     170           0 : }
     171             : 
     172             : #endif /* defined(__linux__) */
     173             : 
     174             : #endif /* HEADER_fd_src_discof_failover_generated_fd_failover_tile_seccomp_h */

Generated by: LCOV version 1.14