LCOV - code coverage report
Current view: top level - app/shared/commands/run/generated - main_seccomp.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 39 0.0 %
Date: 2026-06-29 05:51:35 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_app_shared_commands_run_generated_main_seccomp_h
       3             : #define HEADER_fd_src_app_shared_commands_run_generated_main_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_main_instr_cnt = 34;
      35             : 
      36           0 : static void populate_sock_filter_policy_main( ulong out_cnt, struct sock_filter out[ static 34 ], uint logfile_fd, uint pid_namespace ) {
      37           0 :   FD_TEST( out_cnt >= 34 );
      38           0 :   struct sock_filter filter[34] = {
      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 wait4 */
      49           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_wait4, /* check_wait4 */ 14, 0 ),
      50             :     /* check kill */
      51           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_kill, /* check_kill */ 23, 0 ),
      52             :     /* allow exit_group */
      53           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_exit_group, /* RET_ALLOW */ 1, 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_wait4:
      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)(pid_namespace)), /* and_2 */ 0, /* wait4_KILL */ 6 ),
      84             : //  and_2:
      85             :     /* arg 2 low 32 bits */
      86           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
      87           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(__WALL), /* and_3 */ 0, /* wait4_KILL */ 4 ),
      88             : //  and_3:
      89             :     /* arg 3 high 32 bits */
      90           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(3)),
      91           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_4 */ 0, /* wait4_KILL */ 2 ),
      92             : //  arg_hi_eq_4:
      93             :     /* arg 3 low 32 bits */
      94           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
      95           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* wait4_ALLOW */ 1, /* wait4_KILL */ 0 ),
      96             : //  wait4_KILL:
      97           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      98             : //  wait4_ALLOW:
      99           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     100             : //  check_kill:
     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, FD_SECCOMP_ARG_LO(SIGKILL), /* kill_ALLOW */ 1, /* kill_KILL */ 0 ),
     104             : //  kill_KILL:
     105           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     106             : //  kill_ALLOW:
     107             :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     108           0 :   };
     109           0 :   fd_memcpy( out, filter, sizeof( filter ) );
     110           0 : }
     111             : 
     112             : #endif /* defined(__linux__) */
     113             : 
     114             : #endif /* HEADER_fd_src_app_shared_commands_run_generated_main_seccomp_h */

Generated by: LCOV version 1.14