DragonFlyBSD Kernel Audit
DF-2455 / run.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-2455 run: attempt the FD_STYPE div-by-zero trigger.
#
# NOT REACHABLE on this audit guest: there is no ISA floppy controller (no
# -fda in the QEMU args), so the fdc/fd driver never attaches and /dev/fd0
# does not exist.  Additionally X86_64_GENERIC has no `device fd`, so the
# floppy driver is not even compiled into the kernel.  This is a valid
# HW+config hard blocker (see VERDICT.md).
#
# On a machine WITH a floppy (/dev/fd0 present, root), this would arm and
# trip a kernel divide-by-zero panic:
#     ./fd_stype /dev/fd0        # FD_STYPE sectrac=0 -> d_ncylplanes=size/0
#
# Here we just demonstrate the device is absent (the gate):
set +e
echo "=== checking for a floppy device / FDC (expected: absent) ==="
ls -l /dev/fd0 2>&1
dmesg 2>/dev/null | grep -iE "fdc|floppy" | head
cc -o fd_stype fd_stype.c 2>&1
echo "=== running trigger against (absent) /dev/fd0 ==="
./fd_stype /dev/fd0 2>&1
echo "RUN_EXIT=$?  (open fails ENOENT/ENXIO -> HW-gated, no div-by-zero)"