Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
bpf-helper.h File Reference
#include <asm/bitsperlong.h>
#include <endian.h>
#include <linux/filter.h>
#include <linux/seccomp.h>
#include <linux/types.h>
#include <linux/unistd.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  bpf_labels
 
struct  bpf_labels::__bpf_label
 

Macros

#define BPF_LABELS_MAX   256
 
#define JUMP_JT   0xff
 
#define JUMP_JF   0xff
 
#define LABEL_JT   0xfe
 
#define LABEL_JF   0xfe
 
#define ALLOW   BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW)
 
#define DENY   BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL)
 
#define JUMP(labels, label)
 
#define LABEL(labels, label)
 
#define SYSCALL(nr, jt)
 
#define FIND_LABEL(labels, label)   seccomp_bpf_label((labels), #label)
 
#define EXPAND(...)   __VA_ARGS__
 
#define LO_ARG(idx)   offsetof(struct seccomp_data, args[(idx)])
 
#define ARG_32(idx)   BPF_STMT(BPF_LD+BPF_W+BPF_ABS, LO_ARG(idx))
 
#define ARG_64(idx)
 
#define JEQ32(value, jt)
 
#define JNE32(value, jt)
 
#define JEQ64(lo, hi, jt)
 
#define JNE64(lo, hi, jt)
 
#define JA32(value, jt)
 
#define JA64(lo, hi, jt)
 
#define JGE32(value, jt)
 
#define JLT32(value, jt)
 
#define JGE64(lo, hi, jt)
 
#define JLT64(lo, hi, jt)
 
#define JGT32(value, jt)
 
#define JLE32(value, jt)
 
#define JGT64(lo, hi, jt)
 
#define JLE64(lo, hi, jt)
 
#define LOAD_SYSCALL_NR
 

Functions

int bpf_resolve_jumps (struct bpf_labels *labels, struct sock_filter *filter, size_t count)
 
__u32 seccomp_bpf_label (struct bpf_labels *labels, const char *label)
 
void seccomp_bpf_print (struct sock_filter *filter, size_t count)
 

Macro Definition Documentation

#define ALLOW   BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW)

Definition at line 44 of file bpf-helper.h.

#define ARG_32 (   idx)    BPF_STMT(BPF_LD+BPF_W+BPF_ABS, LO_ARG(idx))

Definition at line 138 of file bpf-helper.h.

#define ARG_64 (   idx)
Value:
BPF_STMT(BPF_ST, 0), /* lo -> M[0] */ \
BPF_STMT(BPF_LD+BPF_W+BPF_ABS, HI_ARG(idx)), \
BPF_STMT(BPF_ST, 1) /* hi -> M[1] */

Definition at line 142 of file bpf-helper.h.

#define BPF_LABELS_MAX   256

Definition at line 25 of file bpf-helper.h.

#define DENY   BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL)

Definition at line 46 of file bpf-helper.h.

#define EXPAND (   ...)    __VA_ARGS__

Definition at line 61 of file bpf-helper.h.

#define FIND_LABEL (   labels,
  label 
)    seccomp_bpf_label((labels), #label)

Definition at line 59 of file bpf-helper.h.

#define JA32 (   value,
  jt 
)
Value:

Definition at line 173 of file bpf-helper.h.

#define JA64 (   lo,
  hi,
  jt 
)
Value:
BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, (hi), 3, 0), \
BPF_STMT(BPF_LD+BPF_MEM, 0), /* swap in lo */ \
BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, (lo), 0, 2), \
BPF_STMT(BPF_LD+BPF_MEM, 1), /* passed: swap hi back in */ \
jt, \
BPF_STMT(BPF_LD+BPF_MEM, 1) /* failed: swap hi back in */

Definition at line 177 of file bpf-helper.h.

#define JEQ32 (   value,
  jt 
)
Value:

Definition at line 148 of file bpf-helper.h.

#define JEQ64 (   lo,
  hi,
  jt 
)
Value:
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (hi), 0, 5), \
BPF_STMT(BPF_LD+BPF_MEM, 0), /* swap in lo */ \
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (lo), 0, 2), \
BPF_STMT(BPF_LD+BPF_MEM, 1), /* passed: swap hi back in */ \
jt, \
BPF_STMT(BPF_LD+BPF_MEM, 1) /* failed: swap hi back in */

Definition at line 157 of file bpf-helper.h.

#define JGE32 (   value,
  jt 
)
Value:

Definition at line 185 of file bpf-helper.h.

#define JGE64 (   lo,
  hi,
  jt 
)
Value:
BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, (hi), 4, 0), \
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (hi), 0, 5), \
BPF_STMT(BPF_LD+BPF_MEM, 0), /* swap in lo */ \
BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, (lo), 0, 2), \
BPF_STMT(BPF_LD+BPF_MEM, 1), /* passed: swap hi back in */ \
jt, \
BPF_STMT(BPF_LD+BPF_MEM, 1) /* failed: swap hi back in */

Definition at line 194 of file bpf-helper.h.

#define JGT32 (   value,
  jt 
)
Value:

Definition at line 212 of file bpf-helper.h.

#define JGT64 (   lo,
  hi,
  jt 
)
Value:
BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, (hi), 4, 0), \
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (hi), 0, 5), \
BPF_STMT(BPF_LD+BPF_MEM, 0), /* swap in lo */ \
BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, (lo), 0, 2), \
BPF_STMT(BPF_LD+BPF_MEM, 1), /* passed: swap hi back in */ \
jt, \
BPF_STMT(BPF_LD+BPF_MEM, 1) /* failed: swap hi back in */

Definition at line 221 of file bpf-helper.h.

#define JLE32 (   value,
  jt 
)
Value:

Definition at line 216 of file bpf-helper.h.

#define JLE64 (   lo,
  hi,
  jt 
)
Value:
BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, (hi), 6, 0), \
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (hi), 0, 3), \
BPF_STMT(BPF_LD+BPF_MEM, 0), /* swap in lo */ \
BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, (lo), 2, 0), \
BPF_STMT(BPF_LD+BPF_MEM, 1), /* passed: swap hi back in */ \
jt, \
BPF_STMT(BPF_LD+BPF_MEM, 1) /* failed: swap hi back in */

Definition at line 230 of file bpf-helper.h.

#define JLT32 (   value,
  jt 
)
Value:

Definition at line 189 of file bpf-helper.h.

#define JLT64 (   lo,
  hi,
  jt 
)
Value:
BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, (hi), 0, 4), \
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (hi), 0, 5), \
BPF_STMT(BPF_LD+BPF_MEM, 0), /* swap in lo */ \
BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, (lo), 2, 0), \
BPF_STMT(BPF_LD+BPF_MEM, 1), /* passed: swap hi back in */ \
jt, \
BPF_STMT(BPF_LD+BPF_MEM, 1) /* failed: swap hi back in */

Definition at line 203 of file bpf-helper.h.

#define JNE32 (   value,
  jt 
)
Value:

Definition at line 152 of file bpf-helper.h.

#define JNE64 (   lo,
  hi,
  jt 
)
Value:
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (hi), 5, 0), \
BPF_STMT(BPF_LD+BPF_MEM, 0), /* swap in lo */ \
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (lo), 2, 0), \
BPF_STMT(BPF_LD+BPF_MEM, 1), /* passed: swap hi back in */ \
jt, \
BPF_STMT(BPF_LD+BPF_MEM, 1) /* failed: swap hi back in */

Definition at line 165 of file bpf-helper.h.

#define JUMP (   labels,
  label 
)
Value:

Definition at line 48 of file bpf-helper.h.

#define JUMP_JF   0xff

Definition at line 40 of file bpf-helper.h.

#define JUMP_JT   0xff

Definition at line 39 of file bpf-helper.h.

#define LABEL (   labels,
  label 
)
Value:

Definition at line 51 of file bpf-helper.h.

#define LABEL_JF   0xfe

Definition at line 42 of file bpf-helper.h.

#define LABEL_JT   0xfe

Definition at line 41 of file bpf-helper.h.

#define LO_ARG (   idx)    offsetof(struct seccomp_data, args[(idx)])

Definition at line 65 of file bpf-helper.h.

#define LOAD_SYSCALL_NR
Value:

Definition at line 239 of file bpf-helper.h.

#define SYSCALL (   nr,
  jt 
)
Value:
jt

Definition at line 54 of file bpf-helper.h.

Function Documentation

int bpf_resolve_jumps ( struct bpf_labels labels,
struct sock_filter filter,
size_t  count 
)

Definition at line 17 of file bpf-helper.c.

__u32 seccomp_bpf_label ( struct bpf_labels labels,
const char label 
)

Definition at line 62 of file bpf-helper.c.

void seccomp_bpf_print ( struct sock_filter filter,
size_t  count 
)

Definition at line 83 of file bpf-helper.c.