~/bend-docscommunity

check.bend checks

raw source on the hub · import bend-osdev-bpf@0.1.0.0/check.bend as Check

7 imports
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B
import bend-osdev-word64@0.1.0.0/word64.bend as W
import ./insn.bend as I
import ./validate.bend as V
import ./bpf.bend as R
import ./seccomp.bend as S

Definitions

def show_run source · line 9 · raw

@r:Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, U32> -> String

def show_ok source · line 16 · raw

@r:Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, Unit> -> String

def show_act source · line 23 · raw

@r:Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, 0x9fae2d11be141cc220d6a37e498b4020/seccomp.SeccompAction> -> String

def rarp source · line 32 · raw

List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfRaw>

bpf(4), EXAMPLES: accept only Reverse ARP requests, as BPF_STMT and BPF_JUMP lines (0x8035 = 32821, ETHERTYPE_REVARP; 3, REVARP_REQUEST)

def run_raw.go source · line 35 · raw

@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @p:Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfOp>> -> Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, U32>

def run_raw source · line 42 · raw

@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @rs:List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfRaw> -> Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, U32>

def hosts source · line 46 · raw

List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfOp>

bpf(4): accept IP packets between 128.3.112.15 and 128.3.112.35

def finger source · line 50 · raw

List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfOp>

bpf(4): accept TCP finger packets (port 79), skipping IP fragments

def pkt_rarp source · line 53 · raw

0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

def pkt_arp source · line 56 · raw

0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

def pkt_ip source · line 59 · raw

@src:List<&2, U32> -> @dst:List<&2, U32> -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

def pkt_finger source · line 62 · raw

0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

def pkt_web source · line 65 · raw

0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

def pkt_frag source · line 68 · raw

0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

def pkt_finger_opts source · line 71 · raw

0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

def pkt_run source · line 74 · raw

@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @prog:List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfOp> -> String

def example source · line 80 · raw

List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfOp>

seccomp(2), EXAMPLES: install_filter(59, AUDIT_ARCH_X86_64, 99): execve (59) fails with errno 99, other calls are allowed, and another architecture or an x32 call kills the process

def sc_call source · line 83 · raw

@nr:U32 -> @arch:U32 -> 0x9fae2d11be141cc220d6a37e498b4020/seccomp.SeccompData

def sc source · line 86 · raw

@prog:List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfOp> -> @d:0x9fae2d11be141cc220d6a37e498b4020/seccomp.SeccompData -> String

def ret_only source · line 89 · raw

@a:0x9fae2d11be141cc220d6a37e498b4020/seccomp.SeccompAction -> List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfOp>

def deny source · line 93 · raw

@nr:U32 -> @e:U32 -> List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfOp>

a filter that answers ERRNO(e) for system call nr and ALLOW otherwise

def big.last source · line 101 · raw

@last:Bool -> 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfRaw

A full-size program, as a regression test for long inputs: 4096 instructions (BPF_MAXINSNS), stored as Octets, read back, prepared and run on 64 KB of pseudo-random bytes (a linear congruential generator). Block j of eight: ld [4j mod 65532]; add #j; st M[j mod 16]; ldx M[j mod 16]; ldx #(7j mod 65000); ldb [x + 3]; jeq #j, 0, 0; ja 0 (ret a in the last).

def big.block source · line 108 · raw

@+j:U32 -> @last:Bool -> @acc:List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfRaw> -> List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfRaw>

def big.prog source · line 113 · raw

@n:Nat -> @+j:U32 -> @+top:U32 -> @acc:List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfRaw> -> List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfRaw>

blocks 0 to j, the last ending in ret a (top is the last block's j)

def big.packet source · line 120 · raw

@n:Nat -> @+s:U32 -> @acc:List<&2, U32> -> List<&2, U32>

def big.run source · line 128 · raw

@r:Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfOp>> -> @pk:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> String

def big.prep source · line 135 · raw

@r:Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfOp>> -> Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, Unit>

def big.read source · line 142 · raw

@r:Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfRaw>> -> @pk:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> String

def huge.read source · line 152 · raw

@r:Result<&2, &2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfError, List<&2, 0x9fae2d11be141cc220d6a37e498b4020/insn.BpfRaw>> -> String

Untrusted input of 32768 instructions (256 KB): refused by bpf_of_octets at its default limit (8 * BPF_MAXINSNS bytes) before the rest is read, and, read with a higher limit, decoded and refused by validation as too long

def main source · line 159 · raw

IO(Unit)