Skip to content

Instantly share code, notes, and snippets.

View tixxdz's full-sized avatar
👽

Djalal Harouni tixxdz

👽
View GitHub Profile
@tixxdz
tixxdz / timgad_test.c
Created February 2, 2017 10:59
Timgad LSM 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 / vm-backup.sh
Created January 23, 2017 10:21 — forked from cabal95/vm-backup.sh
I use this script to backup my QEMU/KVM/libVirt virtual machines. The script requires KVM 2.1+ since it uses the live blockcommit mode. This means the data in the snapshot disk is rolled back into the original instead of the other way around. Script does NOT handle spaces in paths.
#!/bin/bash
#
BACKUPDEST="$1"
DOMAIN="$2"
MAXBACKUPS="$3"
if [ -z "$BACKUPDEST" -o -z "$DOMAIN" ]; then
echo "Usage: ./vm-backup <backup-folder> <domain> [max-backups]"
exit 1
@tixxdz
tixxdz / hidepid_test.c
Created January 16, 2017 11:59
prctl: hidepid test
#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];
@tixxdz
tixxdz / map_fixed.c
Created October 7, 2016 15:36
dumb bad MAP_FXIED
#include <errno.h>
#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
/* MAP_FIXED is bad... map a big ANONYMOUS in the right direction of your addresses and let MAP_FIXED reclame it... */
/* This is wrong and was written quickly it ignores linux mmap_min_addr
* addresses and plenty of bugs ... */
static void *mmap_hint(void *base_addr) {
@tixxdz
tixxdz / userns_test.c
Created June 5, 2016 20:35
usens_test.c
/* userns_child_exec.c
Copyright 2013, Michael Kerrisk
Licensed under GNU General Public License v2 or later
Create a child process that executes a shell command in new
namespace(s); allow UID and GID mappings to be specified when
creating a user namespace.
*/
#define _GNU_SOURCE
@tixxdz
tixxdz / testdetectmachineid-patch
Created April 21, 2016 10:49
testdetectmachineID
index fd5876d..6992144 100644
--- a/functional/node_test.go
+++ b/functional/node_test.go
@@ -162,39 +162,17 @@ func TestDetectMachineId(t *testing.T) {
t.Fatalf("m1: should get an error, but got success.\nstderr: %s", stderr)
}
- // Trigger another test case of m0's ID getting different from m1's.
- // Then it's expected that m0 and m1 would be working properly with distinct
- // machine IDs, after having restarted fleet.service both on m0 and m1.
@tixxdz
tixxdz / 0001-nspawn-just-a-quick-patch-to-test-overlayfs-uid-shif.patch
Created January 21, 2016 11:54
[PATCH] nspawn: just a quick patch to test overlayfs uid shift
From fc07e715ec5c20b461f4fda4014f755a53a39d5a Mon Sep 17 00:00:00 2001
From: Djalal Harouni <djalal@endocode.com>
Date: Thu, 21 Jan 2016 12:49:41 +0100
Subject: [PATCH] nspawn: just a quick patch to test overlayfs uid shift
Signed-off-by: Djalal Harouni <djalal@endocode.com>
---
src/nspawn/nspawn-mount.c | 25 ++++++++++++++++++-------
src/nspawn/nspawn-mount.h | 1 +
src/nspawn/nspawn.c | 1 +
@tixxdz
tixxdz / gist:138870bb04ccf8eb4f95
Created March 3, 2015 15:43
kdbus: memfd: lock inversion
[ 484.608844]
[ 484.609124] =========================================================
[ 484.609124] [ INFO: possible irq lock inversion dependency detected ]
[ 484.609124] 3.19.0+ #8 Tainted: G W OE
[ 484.609124] ---------------------------------------------------------
[ 484.609124] kdbus-test/3167 just changed the state of lock:
[ 484.609124] (&db->entries_rwlock){++++-+}, at: [<ffffffffa02ca9f4>] kdbus_policy_db_clear+0x24/0xa0 [kdbus]
[ 484.609124] but this lock took another, RECLAIM_FS-unsafe lock in the past:
[ 484.609124] (&p->lock#2){+.+.+.}
@tixxdz
tixxdz / gist:301ad06554e27f1c32b8
Created March 2, 2015 22:06
kdbus: memfds accounting
diff --git a/connection.c b/connection.c
index e554f1a..f8b21f7 100644
--- a/connection.c
+++ b/connection.c
@@ -610,14 +610,15 @@ struct kdbus_quota {
uint32_t memory;
uint16_t msgs;
uint8_t fds;
+ uint8_t memfds;
};
[ 376.338853] ------------[ cut here ]------------
[ 376.339772] WARNING: CPU: 3 PID: 1681 at lib/list_debug.c:33 __list_add+0xa0/0xd0()
[ 376.341223] list_add corruption. prev->next should be next (ffff880035e036c8), but was (null). (prev=ffff88006a50db40).
[ 376.343545] Modules linked in: kdbus(OE) ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack cfg80211 rfkill ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_mangle iptable_security iptable_raw ppdev parport_pc parport i2c_piix4 serio_raw 8139too microcode bochs_drm drm_kms_helper ttm drm 8139cp mii ata_generic i2c_core pata_acpi
[ 376.360830] CPU: 3 PID: 1681 Comm: kdbus-test Tainted: G W OE 3.19.0+ #8
[ 376.362397] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[ 376.363667] 0000000000000000 00000000857e4f97 ffff880068c63b88 ffffffff81840da2
[ 376.365165] 000000000000000