Skip to content

Instantly share code, notes, and snippets.

View mrpre's full-sized avatar
💭
I may be slow to respond.

mrpre mrpre

💭
I may be slow to respond.
  • 03:06 (UTC +08:00)
View GitHub Profile
/*
* Reproducer for ATM signaling sigd_send() vulnerability
*
* Bug: net/atm/signaling.c sigd_send() uses user-controlled
* msg->vcc pointer without validation.
*
* Requires: root (CAP_NET_ADMIN) and CONFIG_ATM enabled kernel
*/
#include <stdio.h>
#include <string.h>
/*
* Test program for zswpraw per-cgroup stat.
* Pre-compress data with zstd so kernel zswap can't compress further.
* Dep: apt-get install libzstd-dev
* Build: gcc -o test_zswpraw test_zswpraw.c -lzstd
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@mrpre
mrpre / gist:d9a694cc0e19828ee3bc3b37983fde13
Last active February 4, 2026 07:19
caif_deadloop_repro.c
/*
* caif_deadloop_repro.c - Reproduce handle_tx() infinite loop in caif_serial
* Kernel config:
* CONFIG_CAIF=y
* CONFIG_CAIF_TTY=y
* Root cause: Using a TTY with PORT_UNKNOWN type (e.g., /dev/ttyS3 in QEMU)
* causes uart_write_room() to return 1 but uart_write() to return 0,
* because xmit_buf is never allocated for PORT_UNKNOWN ports.
*
* Compile: gcc -o caif_deadloop_repro caif_deadloop_repro.c
@mrpre
mrpre / caif_uaf_trigger.c
Created February 4, 2026 04:04
Trigger caif_serial UAF bug
/*
* caif_uaf_trigger.c - Trigger caif_serial UAF bug
*
* This program opens a tty, sets N_CAIF line discipline,
* then sends packets to the caif device while closing the tty
* to trigger the use-after-free bug.
*
* Compile: gcc -o caif_uaf_trigger caif_uaf_trigger.c -lpthread
* Run as root: ./caif_uaf_trigger
*/
@mrpre
mrpre / ip_rt_bug_race.c
Created January 28, 2026 08:49
ip_rt_bug reproducer
/*
* ip_rt_bug race condition reproducer
*
* Requires kernel with mdelay(2000) in icmp_route_lookup before ip_route_input.
*
* Race scenario:
* 1. Send packet with src=172.20.20.1 (not local), dst=172.30.0.1
* 2. Malformed IP option triggers icmp_send -> icmp_route_lookup
* 3. First xfrm_lookup returns -EPERM (block policy), enters reverse path
* 4. Kernel delays 2s before ip_route_input