Skip to content

Instantly share code, notes, and snippets.

@drakenclimber
drakenclimber / forkexample.c
Created September 16, 2019 18:42
LSS2019 Seccomp/Libseccomp Tutorial
#include <errno.h> // errno, duh
#include <seccomp.h> // seccomp, duh
#include <stdio.h> // fprintf
#include <stdlib.h> // exit
#include <sys/types.h> // fork
#include <unistd.h> // fork
static const char const mystring[] = "allow this fprintf\n";
void run_child(void)
@drakenclimber
drakenclimber / print_htbl.c
Last active April 4, 2019 19:46
print libseccomp hash table
#include <stdarg.h>
#include <stdio.h>
static void print_line(int indent_level, const char *format, ...)
{
int i;
for (i = 0; i < indent_level; i++)
fprintf(stdout, " ");
va_list(args);
@drakenclimber
drakenclimber / print_chains.c
Last active February 5, 2020 23:15
print libseccomp argument chains
#include <stdarg.h>
#include <stdio.h>
static void print_line(int indent_level, const char *format, ...)
{
int i;
for (i = 0; i < indent_level; i++)
fprintf(stdout, " ");
va_list(args);
@drakenclimber
drakenclimber / print_blks.c
Last active April 15, 2022 16:00
print libseccomp bpf_blks
static void print_instr(struct bpf_instr *instr)
{
fprintf(stdout, "\t\t\t\top = 0x%x\n", instr->op);
fprintf(stdout, "\t\t\t\tjt type = %d hash = 0x%lx\n", instr->jt.type,
instr->jt.tgt.hash);
fprintf(stdout, "\t\t\t\tjf type = %d hash = 0x%lx\n", instr->jf.type,
instr->jf.tgt.hash);
fprintf(stdout, "\t\t\t\tk type = %d hash = 0x%lx\n", instr->k.type,
instr->k.tgt.hash);