Skip to content

Instantly share code, notes, and snippets.

View tixxdz's full-sized avatar
👽

Djalal Harouni tixxdz

👽
View GitHub Profile
@tixxdz
tixxdz / tetragon_cgroups_hierarchies_fixes.md
Last active August 29, 2022 21:23
Tetragon Cgroupv2 ID and Name fixes

Tetragon logs:

Run tetragon standalone then in an other terminal run command id.

  1. Without patch command id on cgroupv2 with only memory and pids controllers
time="2022-08-29T08:49:19+02:00" level=trace msg="process_exec: no container ID due to cgroup name not being a compatible ID, ignoring." cgroup.id=154 cgroup.name=user.slice process.binary=/usr/bin/id process.exec_id=OjQ4OTg5MTU4Mjc3MDY2OjE5MzA1
@tixxdz
tixxdz / gist:534e66734f76c04160adaa1c0c6c9fe3
Created August 25, 2022 09:15
tetragon_test_on_kernel_5.4_without_memory_pids_cgroup_controllers
ime="2022-08-25T09:13:17Z" level=info msg="BPF prog was loaded" label=tracepoint/sys_execve prog=bpf/objs/bpf_execve_event_v53.o
time="2022-08-25T09:13:17Z" level=info msg="Loaded BPF maps and events for sensor successfully" sensor=__main__
time="2022-08-25T09:13:17Z" level=info msg="Cgroup mode detection succeeded" CgroupMode="Unified mode (Cgroupv2)" Cgroupfs=/sys/fs/cgroup
time="2022-08-25T09:13:17Z" level=info msg="Cgroup BPF helpers will run in Cgroupv2 mode or fallback to raw Cgroup on errors" Cgroupfs=/sys/fs/cgroup
time="2022-08-25T09:13:17Z" level=debug msg="Cgroup available controllers" Cgroupfs=/sys/fs/cgroup cgroup.controllers="[cpuset cpu cpuacct freezer]"
time="2022-08-25T09:13:17Z" level=warning msg="Supported cgroup controller 'memory' is not active" Cgroupfs=/sys/fs/cgroup error="controller 'memory' is not active"
time="2022-08-25T09:13:17Z" level=warning msg="Supported cgroup controller 'pids' is not active" Cgroupfs=/sys/fs/cgroup error="controller 'pids' is not active"
time="2022-08-25T09:
@tixxdz
tixxdz / pr_modules_autoload_mode_test.c
Created November 28, 2017 15:20
4.15-rc1 - prctl - module autoload test tool
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/prctl.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
enum {
@tixxdz
tixxdz / pr_modules_autoload_mode_test.c
Created November 27, 2017 11:31
prctl - module autoload mode - v5
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/prctl.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
enum {
@tixxdz
tixxdz / may_autoload_module_new.patch
Created May 24, 2017 13:59
Module: may autoload module function patch
+int may_autoload_module(struct task_struct *task, char *kmod_name,
+ int require_cap, char *prefix)
+{
+ unsigned int autoload;
+ int module_require_cap = 0;
+
+ if (require_cap > 0) {
+ if (prefix == NULL || *prefix == '\0')
+ return -EPERM;
+
@tixxdz
tixxdz / kernel_may_autoload_module.patch
Created May 24, 2017 12:50
Patch for may_autoload_module()
-int may_autoload_module(struct task_struct *task, char *kmod_name, int allow_cap)
+int may_autoload_module(struct task_struct *task, char *kmod_name,
+ int require_cap, char *prefix)
{
- unsigned int autoload = max_t(unsigned int, modules_autoload_mode,
- task->modules_autoload_mode);
+ unsigned int autoload;
+ bool module_require_cap = false;
- if (autoload == MODULES_AUTOLOAD_ALLOWED)
@tixxdz
tixxdz / pr_modules_autoload_mode_test.c
Created May 21, 2017 21:20
modules:capabilities: test for a per-task modules auto-load prctl(PR_SET_MODULES_AUTOLOAD_MODE, ...)
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/prctl.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
enum {
@tixxdz
tixxdz / pr_modules_autoload.c
Created April 18, 2017 19:01
pr_modules_autoload.c
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/prctl.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
extern char **environ;
@tixxdz
tixxdz / modautorestrict_test.c
Created April 8, 2017 11:53
ModAutoRestrict Linux Security Module test
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/prctl.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
extern char **environ;
@tixxdz
tixxdz / prctl_set_pidfs_ptrace_fscreds.c
Created February 13, 2017 15:14
Test PR_SET_PIDFS_PTRACE_FSCREDS
#include <stdio.h>
#include <unistd.h>
#include <linux/prctl.h>
#include <sys/prctl.h>
int main(int argc, const char **argv)
{
int ret;
char *args[2];