Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / whatweactuallywrote.c
Created September 16, 2019 18:44
LSS2019 seccomp/libseccomp Example
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <seccomp.h>
#include <errno.h>
#include <string.h>
static const char const *lss = "LSS NA 2019\n";
@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-struct-cgroup.c
Last active February 6, 2020 03:17
libcgroup print struct cgroup
void print_control_values(const struct control_value * const cv)
{
fprintf(stdout, "\t\tcontrol_value: %s\n", cv->name);
fprintf(stdout, "\t\t\tvalue = %s\n", cv->value);
fprintf(stdout, "\t\t\tmultiline_value = %s\n", cv->multiline_value);
fprintf(stdout, "\t\t\tdirty = %d\n", cv->dirty);
}
void print_controller(const struct cgroup_controller * const controller)
{
@drakenclimber
drakenclimber / find-first-hole-in-each-arch.py
Last active March 5, 2020 15:44
Finds the first invalid syscall (above zero) in each architecture supported by libseccomp
#!/usr/bin/env python3
import os
import subprocess
LIBSECCOMP_SRC_PATH = "/home/thromatka/git/clean/upstream-libseccomp"
arch_list = [
"aarch64",
"arm",
#!/usr/bin/env python3
import os
import subprocess
LIBSECCOMP_DIR="upstream-libseccomp"
DUMP_TOOL=os.path.join(LIBSECCOMP_DIR, "src/arch-syscall-dump")
ARCH_LIST=[
"x86",
"x86_64",
#syscall x86 x86_64 x32 arm aarch64 mips mips64 mips64n32 parisc parisc64 ppc ppc64 s390 s390x
_llseek 140 PNR PNR 140 PNR 140 PNR PNR 140 140 140 140 140 PNR
_newselect 142 PNR PNR 142 PNR 142 22 22 142 142 142 142 142 PNR
_sysctl 149 156 PNR 149 PNR 153 152 152 149 149 149 149 149 149
accept PNR 43 43 285 202 168 42 42 35 35 330 330 PNR PNR
accept4 364 288 288 366 242 334 293 297 320 320 344 344 364 364
access 33 21 21 33 PNR 33 20 20 33 33 33 33 33 33
acct 51 163 163 51 89 51 158 158 51 51 51 51 51 51
add_key 286 248 248 309 217 280 239 243 264 264 269 269 278 278
adjtimex 124 159 159 124 171 124 154 154 124 124 124 124 124 124
--- release-2.4.csv 2020-05-27 13:32:59.203148651 -0600
+++ head-syscalls.csv 2020-06-09 12:18:02.489623475 -0600
@@ -11 +15 @@
-afs_syscall,137,183,183,PNR,PNR,137,176,176,137,137,137,137,137,137
+afs_syscall,137,183,183,PNR,PNR,137,176,176,PNR,PNR,137,137,137,137
@@ -32 +36 @@
-clock_adjtime64,405,PNR,PNR,405,PNR,405,PNR,405,PNR,PNR,405,PNR,405,PNR
+clock_adjtime64,405,PNR,PNR,405,PNR,405,PNR,405,405,PNR,405,PNR,405,PNR
@@ -34 +38 @@
-clock_getres_time64,406,PNR,PNR,406,PNR,406,PNR,406,PNR,PNR,406,PNR,406,PNR
@drakenclimber
drakenclimber / libseccomp v2.4.4 parisc64 syscall diff
Created July 31, 2020 15:43
libseccomp v2.4.4 parisc64 syscall diff
$ ./arch-syscall-validate ~/git/clean/upstream-torvalds/
--- parisc64 [library]
+++ parisc64 [system]
@@ -16,15 +16,10 @@
chown,180
chroot,61
clock_adjtime,324
-clock_adjtime64,405
clock_getres,257
-clock_getres_time64,406