DragonFlyBSD Kernel Audit
DF-0716 / run.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-0716 run — loads smbfs.ko + strdup_test.ko (root-only admin action) and
# fires the TOCTOU race driver.
# Run as root. Expected (bug present): some iterations show stale slab bytes
# (RACE WON). Expected (fixed): zero RACE WON (smb_strdupin returns NULL on
# copyin failure instead of returning stale buffer).
set -e
cd "$(dirname "$0")"

# Ensure smbfs.ko is loaded (provides smb_strdupin/smb_strfree)
if ! kldstat -q -m smbfs; then
	echo "+ kldload smbfs (admin precondition)"
	kldload smbfs
fi

# Load the test harness module
if ! kldstat -q -m strdup_test; then
	echo "+ kldload ./strdup_test.ko"
	kldload ./strdup_test.ko
fi

echo "+ ./strdup_race ${1:-100000}"
./strdup_race "${1:-100000}"