Skip to content

Instantly share code, notes, and snippets.

#ifndef _SECCOMP_RANGES_H
#define _SECCOMP_RANGES_H
#ifdef __cplusplus
extern "C" {
#endif
struct range ranges_x86_64_SCMP_KV_5_04[] = {
{0, 169},
{171, 334},
{424, 445},
@drakenclimber
drakenclimber / libcgroup-read-stats-example.c
Created December 17, 2021 15:52
libcgroup-read-stats-example.c
#include <libcgroup.h>
#include <stdlib.h>
#define CGPATH "stat_example/foo"
#define CONTROLLER "cpu"
int main(void)
{
struct cgroup_stat stat;
void *handle = NULL;
@drakenclimber
drakenclimber / libcgroup-cgxget-example.c
Last active November 8, 2021 22:06
Example of how to use the newly proposed cgroup_cgxget() and cgroup_cgxset() C APIs.
#include <libcgroup.h>
#include <stdlib.h>
#define CGNAME "cgx_example"
#define CONTROLLER "cpu"
#define SETTING "cpu.shares"
#define VALUE "999"
static int other_interesting_calls(void)
{
@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
--- 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
#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
#!/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",
@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",
@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 / 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";