LCOV - code coverage report
Current view: top level - disco/netlink/generated - netlink_seccomp.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 82 0.0 %
Date: 2026-09-14 04:30:10 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_netlink_generated_netlink_seccomp_h
       3             : #define HEADER_fd_src_disco_netlink_generated_netlink_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_netlink_instr_cnt = 77;
      35             : 
      36           0 : static void populate_sock_filter_policy_netlink( ulong out_cnt, struct sock_filter out[ static 77 ], uint logfile_fd, uint nl_mon_fd, uint nl_req_fd, uint arp_probe_fd, uint epoll_inner_fd, uint epoll_outer_fd ) {
      37           0 :   FD_TEST( out_cnt >= 77 );
      38           0 :   struct sock_filter filter[77] = {
      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 */ 7 ),
      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 */ 7, 0 ),
      46             :     /* check fsync */
      47           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 12, 0 ),
      48             :     /* check sendto */
      49           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_sendto, /* check_sendto */ 15, 0 ),
      50             :     /* check recvfrom */
      51           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_recvfrom, /* check_recvfrom */ 40, 0 ),
      52             :     /* check epoll_ctl */
      53           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_epoll_ctl, /* check_epoll_ctl */ 57, 0 ),
      54             :     /* check clock_nanosleep */
      55           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_clock_nanosleep, /* check_clock_nanosleep */ 62, 0 ),
      56             : //  RET_KILL_PROCESS:
      57             :     /* default deny */
      58           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      59             : //  RET_ALLOW:
      60             :     /* allow */
      61           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      62             : //  check_write:
      63             :     /* arg 0 low 32 bits */
      64           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      65           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000002U, /* write_ALLOW */ 3, /* or_1 */ 0 ),
      66             : //  or_1:
      67             :     /* arg 0 low 32 bits */
      68           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      69           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* write_ALLOW */ 1, /* write_KILL */ 0 ),
      70             : //  write_KILL:
      71           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      72             : //  write_ALLOW:
      73           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      74             : //  check_fsync:
      75             :     /* arg 0 low 32 bits */
      76           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      77           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(logfile_fd)), /* fsync_ALLOW */ 1, /* fsync_KILL */ 0 ),
      78             : //  fsync_KILL:
      79           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      80             : //  fsync_ALLOW:
      81           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      82             : //  check_sendto:
      83             :     /* arg 0 low 32 bits */
      84           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
      85           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(nl_req_fd)), /* and_3 */ 0, /* or_2 */ 8 ),
      86             : //  and_3:
      87             :     /* arg 3 low 32 bits */
      88           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
      89           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_4 */ 0, /* or_2 */ 6 ),
      90             : //  and_4:
      91             :     /* arg 4 high 32 bits */
      92           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(4)),
      93           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_6 */ 0, /* or_2 */ 4 ),
      94             : //  arg_hi_eq_6:
      95             :     /* arg 4 low 32 bits */
      96           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(4)),
      97           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_5 */ 0, /* or_2 */ 2 ),
      98             : //  and_5:
      99             :     /* arg 5 low 32 bits */
     100           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(5)),
     101           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* sendto_ALLOW */ 15, /* or_2 */ 0 ),
     102             : //  or_2:
     103             :     /* arg 0 low 32 bits */
     104           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     105           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(arp_probe_fd)), /* and_7 */ 0, /* sendto_KILL */ 12 ),
     106             : //  and_7:
     107             :     /* arg 1 high 32 bits */
     108           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(1)),
     109           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_9 */ 0, /* sendto_KILL */ 10 ),
     110             : //  arg_hi_eq_9:
     111             :     /* arg 1 low 32 bits */
     112           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
     113           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_8 */ 0, /* sendto_KILL */ 8 ),
     114             : //  and_8:
     115             :     /* arg 2 high 32 bits */
     116           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(2)),
     117           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_11 */ 0, /* sendto_KILL */ 6 ),
     118             : //  arg_hi_eq_11:
     119             :     /* arg 2 low 32 bits */
     120           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
     121           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_10 */ 0, /* sendto_KILL */ 4 ),
     122             : //  and_10:
     123             :     /* arg 3 low 32 bits */
     124           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
     125           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_DONTWAIT), /* and_12 */ 0, /* sendto_KILL */ 2 ),
     126             : //  and_12:
     127             :     /* arg 5 low 32 bits */
     128           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(5)),
     129           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(FD_SOCKADDR_IN_SZ), /* sendto_ALLOW */ 1, /* sendto_KILL */ 0 ),
     130             : //  sendto_KILL:
     131           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     132             : //  sendto_ALLOW:
     133           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     134             : //  check_recvfrom:
     135             :     /* arg 0 low 32 bits */
     136           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     137           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(nl_mon_fd)), /* and_13 */ 2, /* or_14 */ 0 ),
     138             : //  or_14:
     139             :     /* arg 0 low 32 bits */
     140           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     141           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(nl_req_fd)), /* and_13 */ 0, /* recvfrom_KILL */ 12 ),
     142             : //  and_13:
     143             :     /* arg 3 low 32 bits */
     144           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
     145           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_15 */ 2, /* or_16 */ 0 ),
     146             : //  or_16:
     147             :     /* arg 3 low 32 bits */
     148           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(3)),
     149           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(MSG_DONTWAIT), /* and_15 */ 0, /* recvfrom_KILL */ 8 ),
     150             : //  and_15:
     151             :     /* arg 4 high 32 bits */
     152           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(4)),
     153           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_18 */ 0, /* recvfrom_KILL */ 6 ),
     154             : //  arg_hi_eq_18:
     155             :     /* arg 4 low 32 bits */
     156           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(4)),
     157           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* and_17 */ 0, /* recvfrom_KILL */ 4 ),
     158             : //  and_17:
     159             :     /* arg 5 high 32 bits */
     160           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_HI_OFFSET(5)),
     161           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* arg_hi_eq_19 */ 0, /* recvfrom_KILL */ 2 ),
     162             : //  arg_hi_eq_19:
     163             :     /* arg 5 low 32 bits */
     164           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(5)),
     165           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* recvfrom_ALLOW */ 1, /* recvfrom_KILL */ 0 ),
     166             : //  recvfrom_KILL:
     167           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     168             : //  recvfrom_ALLOW:
     169           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     170             : //  check_epoll_ctl:
     171             :     /* arg 0 low 32 bits */
     172           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     173           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(epoll_outer_fd)), /* and_20 */ 0, /* epoll_ctl_KILL */ 2 ),
     174             : //  and_20:
     175             :     /* arg 2 low 32 bits */
     176           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(2)),
     177           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, ((uint)(epoll_inner_fd)), /* epoll_ctl_ALLOW */ 1, /* epoll_ctl_KILL */ 0 ),
     178             : //  epoll_ctl_KILL:
     179           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     180             : //  epoll_ctl_ALLOW:
     181           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     182             : //  check_clock_nanosleep:
     183             :     /* arg 0 low 32 bits */
     184           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(0)),
     185           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, FD_SECCOMP_ARG_LO(CLOCK_REALTIME), /* and_21 */ 0, /* clock_nanosleep_KILL */ 2 ),
     186             : //  and_21:
     187             :     /* arg 1 low 32 bits */
     188           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, FD_SECCOMP_ARG_LO_OFFSET(1)),
     189           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 0x00000000U, /* clock_nanosleep_ALLOW */ 1, /* clock_nanosleep_KILL */ 0 ),
     190             : //  clock_nanosleep_KILL:
     191           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
     192             : //  clock_nanosleep_ALLOW:
     193             :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
     194           0 :   };
     195           0 :   fd_memcpy( out, filter, sizeof( filter ) );
     196           0 : }
     197             : 
     198             : #endif /* defined(__linux__) */
     199             : 
     200             : #endif /* HEADER_fd_src_disco_netlink_generated_netlink_seccomp_h */

Generated by: LCOV version 1.14