DragonFlyBSD Kernel Audit
DF-0764 / run.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-0764 run.sh — set up FFS+softdep, run churn, try unmount.
# Must run as root. The bug is in kernel softdep worklist code, so the user's
# privilege is irrelevant for triggering; an unprivileged user with
# vfs.usermount=1 and a root-created image hits the same path.
set -u
MP=/mnt/ffs
IMG=/tmp/ffs.img
DUR=${1:-30}
NW=${2:-8}

echo "=== creating FFS image with softupdates ==="
truncate -s 256M "$IMG" 2>/dev/null || dd if=/dev/zero of="$IMG" bs=1m count=256 2>/dev/null
vnconfig -c vn0 "$IMG" 2>/dev/null
newfs -U /dev/vn0 2>&1 | tail -4
mkdir -p "$MP"
mount_ufs /dev/vn0 "$MP" 2>/dev/null || mount -t ufs /dev/vn0 "$MP"
echo "=== mount state ==="
mount | grep "$MP"

echo "=== running churn ${DUR}s x ${NW} workers ==="
./softdep_churn "$MP" "$DUR" "$NW"

echo "=== attempting unmount (panic here => softdep_flushfiles looping) ==="
umount "$MP" 2>&1
RC=$?
echo "umount rc=$RC"
if [ $RC -eq 0 ]; then
    echo "UNMOUNT_OK (no panic; race may not have fired)"
fi