$ cat writeup.md…
$ cat writeup.md…
Hack.lu CTF 2026
Task: Linux 6.19 kernel module /dev/agile-kv with 20 rbtree ticket stores; ticket_set_priority() locks only the source store and inserts unlocked into the destination. Solution: race INC/DEC_PRIO for duplicate linkage, cross-cache reclaim with pipe_buffer and msg_msg, leak KASLR, overwrite task->cred with &init_cred.
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
Challenge files:
chal.c,chal.h,chal.ko,bzImage,vmlinux,initramfs.cpio.gz,run.sh,Dockerfile,docker-compose.yml,config. Flag formatflag{...}. Author: donc42.
English summary: the guest boots a Linux 6.19.9-chal kernel with a loadable module that
creates a char device /dev/agile-kv (mode 0666). The module implements a "ticket store":
20 red-black trees ticket_stores[20] indexed by a priority 0..19. An unprivileged user
(uid 1000) can create, read and delete tickets and move them between priority stores. The flag
sits on the block device /dev/vda (mode 400, owned by root), so the goal is a local
privilege escalation to uid 0.
struct ticket { char subject[0x100]; char description[0x200]; long id; int priority; struct rb_node node; }; /* 0x328 */ struct user_ticket { unsigned int priority; unsigned long id; char *subject; char *description; unsigned long subject_len; unsigned long description_len; };
| ioctl | value |
|---|---|
TICKET_OPEN | 0x1337 |
TICKET_CLOSE | 0x1338 |
TICKET_READ | 0x1339 |
INC_PRIO | 0x133a |
DEC_PRIO | 0x133b |
The backing cache is created with a very specific geometry:
struct kmem_cache_args args = { .sheaf_capacity = 16, .align = 0x400, /* 1024-byte stride */ .useroffset = offsetof(struct ticket, subject), /* 0 */ .usersize = DESC_LEN + SUBJ_LEN /* 0x300 */ }; tickets_cache = kmem_cache_create("tickets-cache", sizeof(struct ticket), &args, 0);
0x328 rounds up to a 0x400 object, 0x400 * 16 = 0x4000 → the cache is order-2, 16
objects per slab. The usercopy region stops at 0x300, i.e. subject, description and
id are user-visible but priority and the embedded struct rb_node are not.
Every other handler locks the store it touches. ticket_set_priority(), which implements
INC_PRIO/DEC_PRIO, does not:
...
$ grep --similar