LCOV - code coverage report
Current view: top level - disco/plugin/generated - fd_bundle_tile_seccomp.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 83 0.0 %
Date: 2025-03-20 12:08:36 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_plugin_generated_fd_bundle_tile_seccomp_h
       3             : #define HEADER_fd_src_disco_plugin_generated_fd_bundle_tile_seccomp_h
       4             : 
       5             : #include "../../../../src/util/fd_util_base.h"
       6             : #include <linux/audit.h>
       7             : #include <linux/capability.h>
       8             : #include <linux/filter.h>
       9             : #include <linux/seccomp.h>
      10             : #include <linux/bpf.h>
      11             : #include <sys/syscall.h>
      12             : #include <signal.h>
      13             : #include <stddef.h>
      14             : 
      15             : #if defined(__i386__)
      16             : # define ARCH_NR  AUDIT_ARCH_I386
      17             : #elif defined(__x86_64__)
      18             : # define ARCH_NR  AUDIT_ARCH_X86_64
      19             : #elif defined(__aarch64__)
      20             : # define ARCH_NR AUDIT_ARCH_AARCH64
      21             : #else
      22             : # error "Target architecture is unsupported by seccomp."
      23             : #endif
      24             : static const unsigned int sock_filter_policy_fd_bundle_tile_instr_cnt = 77;
      25             : 
      26           0 : static void populate_sock_filter_policy_fd_bundle_tile( ulong out_cnt, struct sock_filter * out, unsigned int logfile_fd) {
      27           0 :   FD_TEST( out_cnt >= 77 );
      28           0 :   struct sock_filter filter[77] = {
      29             :     /* Check: Jump to RET_KILL_PROCESS if the script's arch != the runtime arch */
      30           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, arch ) ) ),
      31           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ARCH_NR, 0, /* RET_KILL_PROCESS */ 73 ),
      32             :     /* loading syscall number in accumulator */
      33           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) ) ),
      34             :     /* allow fsync based on expression */
      35           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 25, 0 ),
      36             :     /* simply allow getrandom */
      37           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_getrandom, /* RET_ALLOW */ 71, 0 ),
      38             :     /* allow epoll_create1 based on expression */
      39           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_epoll_create1, /* check_epoll_create1 */ 25, 0 ),
      40             :     /* allow eventfd2 based on expression */
      41           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_eventfd2, /* check_eventfd2 */ 26, 0 ),
      42             :     /* simply allow epoll_ctl */
      43           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_epoll_ctl, /* RET_ALLOW */ 68, 0 ),
      44             :     /* simply allow epoll_wait */
      45           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_epoll_wait, /* RET_ALLOW */ 67, 0 ),
      46             :     /* allow socket based on expression */
      47           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_socket, /* check_socket */ 25, 0 ),
      48             :     /* simply allow connect */
      49           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_connect, /* RET_ALLOW */ 65, 0 ),
      50             :     /* allow fcntl based on expression */
      51           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fcntl, /* check_fcntl */ 29, 0 ),
      52             :     /* allow setsockopt based on expression */
      53           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_setsockopt, /* check_setsockopt */ 36, 0 ),
      54             :     /* allow getsockopt based on expression */
      55           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_getsockopt, /* check_getsockopt */ 47, 0 ),
      56             :     /* simply allow recvfrom */
      57           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_recvfrom, /* RET_ALLOW */ 61, 0 ),
      58             :     /* simply allow sendto */
      59           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* RET_ALLOW */ 60, 0 ),
      60             :     /* simply allow write */
      61           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* RET_ALLOW */ 59, 0 ),
      62             :     /* simply allow writev */
      63           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_writev, /* RET_ALLOW */ 58, 0 ),
      64             :     /* allow shutdown based on expression */
      65           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_shutdown, /* check_shutdown */ 50, 0 ),
      66             :     /* simply allow close */
      67           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_close, /* RET_ALLOW */ 56, 0 ),
      68             :     /* allow mmap based on expression */
      69           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_mmap, /* check_mmap */ 50, 0 ),
      70             :     /* simply allow brk */
      71           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_brk, /* RET_ALLOW */ 54, 0 ),
      72             :     /* simply allow rt_sigaction */
      73           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_rt_sigaction, /* RET_ALLOW */ 53, 0 ),
      74             :     /* simply allow rt_sigprocmask */
      75           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_rt_sigprocmask, /* RET_ALLOW */ 52, 0 ),
      76             :     /* simply allow getpid */
      77           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_getpid, /* RET_ALLOW */ 51, 0 ),
      78             :     /* simply allow gettid */
      79           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_gettid, /* RET_ALLOW */ 50, 0 ),
      80             :     /* simply allow tgkill */
      81           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_tgkill, /* RET_ALLOW */ 49, 0 ),
      82             :     /* simply allow madvise */
      83           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_madvise, /* RET_ALLOW */ 48, 0 ),
      84             :     /* none of the syscalls matched */
      85           0 :     { BPF_JMP | BPF_JA, 0, 0, /* RET_KILL_PROCESS */ 46 },
      86             : //  check_fsync:
      87             :     /* load syscall argument 0 in accumulator */
      88           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      89           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_ALLOW */ 45, /* RET_KILL_PROCESS */ 44 ),
      90             : //  check_epoll_create1:
      91             :     /* load syscall argument 0 in accumulator */
      92           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      93           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, EPOLL_CLOEXEC, /* RET_ALLOW */ 43, /* RET_KILL_PROCESS */ 42 ),
      94             : //  check_eventfd2:
      95             :     /* load syscall argument 1 in accumulator */
      96           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
      97           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, EFD_CLOEXEC|EFD_NONBLOCK, /* RET_ALLOW */ 41, /* RET_KILL_PROCESS */ 40 ),
      98             : //  check_socket:
      99             :     /* load syscall argument 0 in accumulator */
     100           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
     101           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, AF_INET, /* lbl_1 */ 0, /* RET_KILL_PROCESS */ 38 ),
     102             : //  lbl_1:
     103             :     /* load syscall argument 1 in accumulator */
     104           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
     105           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOCK_STREAM|SOCK_CLOEXEC, /* lbl_2 */ 0, /* RET_KILL_PROCESS */ 36 ),
     106             : //  lbl_2:
     107             :     /* load syscall argument 2 in accumulator */
     108           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
     109           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, IPPROTO_TCP, /* RET_ALLOW */ 35, /* RET_KILL_PROCESS */ 34 ),
     110             : //  check_fcntl:
     111             :     /* load syscall argument 1 in accumulator */
     112           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
     113           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, F_GETFL, /* RET_ALLOW */ 33, /* lbl_3 */ 0 ),
     114             : //  lbl_3:
     115             :     /* load syscall argument 1 in accumulator */
     116           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
     117           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, F_SETFL, /* lbl_5 */ 0, /* lbl_4 */ 2 ),
     118             : //  lbl_5:
     119             :     /* load syscall argument 2 in accumulator */
     120           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
     121           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, O_RDWR|O_NONBLOCK, /* RET_ALLOW */ 29, /* lbl_4 */ 0 ),
     122             : //  lbl_4:
     123             :     /* load syscall argument 1 in accumulator */
     124           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
     125           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, F_DUPFD_CLOEXEC, /* RET_ALLOW */ 27, /* RET_KILL_PROCESS */ 26 ),
     126             : //  check_setsockopt:
     127             :     /* load syscall argument 1 in accumulator */
     128           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
     129           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOL_SOCKET, /* lbl_7 */ 0, /* lbl_6 */ 2 ),
     130             : //  lbl_7:
     131             :     /* load syscall argument 2 in accumulator */
     132           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
     133           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SO_KEEPALIVE, /* RET_ALLOW */ 23, /* lbl_6 */ 0 ),
     134             : //  lbl_6:
     135             :     /* load syscall argument 1 in accumulator */
     136           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
     137           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOL_TCP, /* lbl_9 */ 0, /* lbl_8 */ 2 ),
     138             : //  lbl_9:
     139             :     /* load syscall argument 2 in accumulator */
     140           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
     141           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, TCP_KEEPIDLE, /* RET_ALLOW */ 19, /* lbl_8 */ 0 ),
     142             : //  lbl_8:
     143             :     /* load syscall argument 1 in accumulator */
     144           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
     145           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOL_TCP, /* lbl_10 */ 0, /* RET_KILL_PROCESS */ 16 ),
     146             : //  lbl_10:
     147             :     /* load syscall argument 2 in accumulator */
     148           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
     149           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, TCP_NODELAY, /* RET_ALLOW */ 15, /* RET_KILL_PROCESS */ 14 ),
     150             : //  check_getsockopt:
     151             :     /* load syscall argument 1 in accumulator */
     152           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
     153           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOL_TCP, /* lbl_12 */ 0, /* lbl_11 */ 2 ),
     154             : //  lbl_12:
     155             :     /* load syscall argument 2 in accumulator */
     156           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
     157           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, TCP_NODELAY, /* RET_ALLOW */ 11, /* lbl_11 */ 0 ),
     158             : //  lbl_11:
     159             :     /* load syscall argument 1 in accumulator */
     160           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
     161           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SOL_SOCKET, /* lbl_13 */ 0, /* RET_KILL_PROCESS */ 8 ),
     162             : //  lbl_13:
     163             :     /* load syscall argument 2 in accumulator */
     164           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
     165           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SO_ERROR, /* RET_ALLOW */ 7, /* RET_KILL_PROCESS */ 6 ),
     166             : //  check_shutdown:
     167             :     /* load syscall argument 1 in accumulator */
     168           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[1])),
     169           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SHUT_WR, /* RET_ALLOW */ 5, /* RET_KILL_PROCESS */ 4 ),
     170             : //  check_mmap:
     171             :     /* load syscall argument 2 in accumulator */
     172           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
     173           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, PROT_READ|PROT_WRITE, /* RET_ALLOW */ 3, /* lbl_14 */ 0 ),
     174             : //  lbl_14:
     175             :     /* load syscall argument 2 in accumulator */
     176           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[2])),
     177           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, PROT_NONE, /* RET_ALLOW */ 1, /* RET_KILL_PROCESS */ 0 ),
     178             : //  RET_KILL_PROCESS:
     179             :     /* KILL_PROCESS is placed before ALLOW since it's the fallthrough case. */
     180           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     181             : //  RET_ALLOW:
     182             :     /* ALLOW has to be reached by jumping */
     183           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     184           0 :   };
     185           0 :   fd_memcpy( out, filter, sizeof( filter ) );
     186           0 : }
     187             : 
     188             : #endif

Generated by: LCOV version 1.14