Skip to content

Instantly share code, notes, and snippets.

View giuseppe's full-sized avatar

Giuseppe Scrivano giuseppe

View GitHub Profile
@giuseppe
giuseppe / notes.md
Created July 5, 2019 20:52
Note for cgroups v2 Kubernetes

Enable cgroups v2

# grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=1"
# cat /etc/systemd/system/enable-cgroups.service 
[Service]
ExecStart=/bin/sh -c 'echo "+io +cpu +memory +pids +cpuset" > /sys/fs/cgroup/cgroup.subtree_control; mkdir /sys/fs/cgroup/user.slice; echo "+io +cpu +memory +pids +cpuset" > /sys/fs/cgroup/user.slice/cgroup.subtree_control'
Type=oneshot

[Install]
WantedBy=multi-user.target
@giuseppe
giuseppe / Makefile
Last active September 14, 2019 16:20
fuse-overlayfs shared storage
# All files must be copied under the fuse-overlayfs root source directory
all: test-plugin.so convert
test-plugin.so:
gcc -fPIC -I $(pwd) -shared -o test-plugin.so test-plugin.c utils.c
convert:
gcc convert.c -o convert
#!/usr/bin/python3
#
# profile *sync* syscalls.
#
# Based on existing programs that have these copyrights:
# Copyright (c) 2015 Brendan Gregg.
# Licensed under the Apache License, Version 2.0 (the "License")
#
# 13-Aug-2015 Brendan Gregg Created this.
# 19-Feb-2016 Allan McAleavy migrated to BPF_PERF_OUTPUT
@giuseppe
giuseppe / go.mod
Created July 6, 2020 19:43
systemd inhibit PoC
module inhibit
go 1.13
require (
github.com/godbus/dbus/v5 v5.0.3
)
/*
* io_uring_chcon.c
*
* Copyright (C) 2021 Giuseppe Scrivano <[email protected]>
* io_uring_chcon is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* io_uring_chcon is distributed in the hope that it will be useful,
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
#include <sys/sysmacros.h>
#include <sys/xattr.h>
#include <unistd.h>
@giuseppe
giuseppe / sparse_file_writer.go
Last active February 20, 2024 12:16
PoC create a sparse file
package main
import (
"bytes"
"errors"
"io"
"os"
)
type state int