LCOV - code coverage report
Current view: top level - app/fdctl/run/tiles/generated - pack_seccomp.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 20 0.0 %
Date: 2024-11-13 11:58:15 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_fdctl_run_tiles_generated_pack_seccomp_h
       3             : #define HEADER_fd_src_app_fdctl_run_tiles_generated_pack_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_pack_instr_cnt = 14;
      25             : 
      26           0 : static void populate_sock_filter_policy_pack( ulong out_cnt, struct sock_filter * out, unsigned int logfile_fd) {
      27           0 :   FD_TEST( out_cnt >= 14 );
      28           0 :   struct sock_filter filter[14] = {
      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 */ 10 ),
      32             :     /* loading syscall number in accumulator */
      33           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, ( offsetof( struct seccomp_data, nr ) ) ),
      34             :     /* allow write based on expression */
      35           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_write, /* check_write */ 2, 0 ),
      36             :     /* allow fsync based on expression */
      37           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, SYS_fsync, /* check_fsync */ 5, 0 ),
      38             :     /* none of the syscalls matched */
      39           0 :     { BPF_JMP | BPF_JA, 0, 0, /* RET_KILL_PROCESS */ 6 },
      40             : //  check_write:
      41             :     /* load syscall argument 0 in accumulator */
      42           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      43           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, 2, /* RET_ALLOW */ 5, /* lbl_1 */ 0 ),
      44             : //  lbl_1:
      45             :     /* load syscall argument 0 in accumulator */
      46           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      47           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_ALLOW */ 3, /* RET_KILL_PROCESS */ 2 ),
      48             : //  check_fsync:
      49             :     /* load syscall argument 0 in accumulator */
      50           0 :     BPF_STMT( BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, args[0])),
      51           0 :     BPF_JUMP( BPF_JMP | BPF_JEQ | BPF_K, logfile_fd, /* RET_ALLOW */ 1, /* RET_KILL_PROCESS */ 0 ),
      52             : //  RET_KILL_PROCESS:
      53             :     /* KILL_PROCESS is placed before ALLOW since it's the fallthrough case. */
      54           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS ),
      55             : //  RET_ALLOW:
      56             :     /* ALLOW has to be reached by jumping */
      57           0 :     BPF_STMT( BPF_RET | BPF_K, SECCOMP_RET_ALLOW ),
      58           0 :   };
      59           0 :   fd_memcpy( out, filter, sizeof( filter ) );
      60           0 : }
      61             : 
      62             : #endif

Generated by: LCOV version 1.14