LCOV - code coverage report
Current view: top level - disco/net/xdp/generated - fd_xdp_tile_seccomp.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 65 0.0 %
Date: 2026-06-29 05:51:35 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_disco_net_xdp_generated_fd_xdp_tile_seccomp_h
       3             : #define HEADER_fd_src_disco_net_xdp_generated_fd_xdp_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             : 
      28             : #define FD_SECCOMP_ARG_LO_OFFSET(argno) ( offsetof( struct seccomp_data, args[(argno)] ) )
      29             : #define FD_SECCOMP_ARG_HI_OFFSET(argno) ( offsetof( struct seccomp_data, args[(argno)] ) + 4U )
      30             : 
      31             : #define FD_SECCOMP_ARG_LO(x) ((uint)(((ulong)(uint)(int)(x)      ) & 0xffffffffUL))
      32             : #define FD_SECCOMP_ARG_HI(x) ((uint)(((ulong)(x) >> 32) & 0xffffffffUL))
      33             : 
      34             : static const uint sock_filter_policy_fd_xdp_tile_instr_cnt = 60;
      35             : 
      36           0 : static void populate_sock_filter_policy_fd_xdp_tile( ulong out_cnt, struct sock_filter out[ static 60 ], uint logfile_fd, uint xsk_fd, uint lo_xsk_fd ) {
      37           0 :   FD_TEST( out_cnt >= 60 );
      38           0 :   struct sock_filter filter[60] = {
      39             :     /* validate architecture */
      40           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, arch ) )),
      41           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ARCH_NR, 0, /* RET_KILL_PROCESS */ 6 ),
      42             :     /* load syscall number */
      43           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) )),
      44             :     /* check write */
      45           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* check_write */ 6, 0 ),
      46             :     /* check fsync */
      47           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 11, 0 ),
      48             :     /* check sendto */
      49           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 14, 0 ),
      50             :     /* check recvmsg */
      51           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_recvmsg, /* check_recvmsg */ 35, 0 ),
      52             :     /* check getsockopt */
      53           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_getsockopt, /* check_getsockopt */ 42, 0 ),
      54             : //  RET_KILL_PROCESS:
      55             :     /* default deny */
      56           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      57             : //  RET_ALLOW:
      58             :     /* allow */
      59           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      60             : //  check_write:
      61             :     /* arg 0 low 32 bits */
      62           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      63           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 3, /* or_1 */ 0 ),
      64             : //  or_1:
      65             :     /* arg 0 low 32 bits */
      66           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      67           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
      68             : //  write_KILL:
      69           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      70             : //  write_ALLOW:
      71           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      72             : //  check_fsync:
      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)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
      76             : //  fsync_KILL:
      77           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      78             : //  fsync_ALLOW:
      79           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      80             : //  check_sendto:
      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)(xsk_fd)), /* and_2 */ 2, /* or_3 */ 0 ),
      84             : //  or_3:
      85             :     /* arg 0 low 32 bits */
      86           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      87           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(lo_xsk_fd)), /* and_2 */ 0, /* sendto_KILL */ 16 ),
      88             : //  and_2:
      89             :     /* arg 1 high 32 bits */
      90           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(1)),
      91           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_5 */ 0, /* sendto_KILL */ 14 ),
      92             : //  arg_hi_eq_5:
      93             :     /* arg 1 low 32 bits */
      94           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
      95           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_4 */ 0, /* sendto_KILL */ 12 ),
      96             : //  and_4:
      97             :     /* arg 2 high 32 bits */
      98           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(2)),
      99           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_7 */ 0, /* sendto_KILL */ 10 ),
     100             : //  arg_hi_eq_7:
     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, /* and_6 */ 0, /* sendto_KILL */ 8 ),
     104             : //  and_6:
     105             :     /* arg 3 low 32 bits */
     106           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
     107           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_DONTWAIT), /* and_8 */ 0, /* sendto_KILL */ 6 ),
     108             : //  and_8:
     109             :     /* arg 4 high 32 bits */
     110           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(4)),
     111           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_10 */ 0, /* sendto_KILL */ 4 ),
     112             : //  arg_hi_eq_10:
     113             :     /* arg 4 low 32 bits */
     114           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(4)),
     115           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_9 */ 0, /* sendto_KILL */ 2 ),
     116             : //  and_9:
     117             :     /* arg 5 low 32 bits */
     118           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(5)),
     119           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* sendto_ALLOW */ 1, /* sendto_KILL */ 0 ),
     120             : //  sendto_KILL:
     121           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     122             : //  sendto_ALLOW:
     123           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     124             : //  check_recvmsg:
     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, ((uint)(xsk_fd)), /* and_11 */ 2, /* or_12 */ 0 ),
     128             : //  or_12:
     129             :     /* arg 0 low 32 bits */
     130           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     131           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(lo_xsk_fd)), /* and_11 */ 0, /* recvmsg_KILL */ 2 ),
     132             : //  and_11:
     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(MSG_DONTWAIT), /* recvmsg_ALLOW */ 1, /* recvmsg_KILL */ 0 ),
     136             : //  recvmsg_KILL:
     137           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     138             : //  recvmsg_ALLOW:
     139           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     140             : //  check_getsockopt:
     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)(xsk_fd)), /* and_13 */ 2, /* or_14 */ 0 ),
     144             : //  or_14:
     145             :     /* arg 0 low 32 bits */
     146           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     147           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(lo_xsk_fd)), /* and_13 */ 0, /* getsockopt_KILL */ 4 ),
     148             : //  and_13:
     149             :     /* arg 1 low 32 bits */
     150           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
     151           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(SOL_XDP), /* and_15 */ 0, /* getsockopt_KILL */ 2 ),
     152             : //  and_15:
     153             :     /* arg 2 low 32 bits */
     154           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
     155           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(XDP_STATISTICS), /* getsockopt_ALLOW */ 1, /* getsockopt_KILL */ 0 ),
     156             : //  getsockopt_KILL:
     157           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     158             : //  getsockopt_ALLOW:
     159             :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     160           0 :   };
     161           0 :   fd_memcpy( out, filter, sizeof( filter ) );
     162           0 : }
     163             : 
     164             : #endif /* defined(__linux__) */
     165             : 
     166             : #endif /* HEADER_fd_src_disco_net_xdp_generated_fd_xdp_tile_seccomp_h */

Generated by: LCOV version 1.14