⬢ DragonFlyBSD Kernel Audit
DF-5418 / fix_validate.sh
← back to finding ↓ download raw
#!/bin/sh
# Fix validation — run INSIDE the guest after the baseline build+run.
# Phase A: install the DF-5418-fixed ppb_1284.c (ppb_1284.fixA.c =
#          pristine + fix.diff: "!spin" -> "spin < 0"), rebuild, re-run.
# Phase B: install the additionally DF-5419-fixed variant (ppb_1284.fixB.c =
#          fixA + "*read = 0;" in ppb_1284_read_id), rebuild, re-run.
# The pristine production source is restored at the end (and verified).
set -e
SRC=/usr/src/sys/bus/ppbus/ppb_1284.c
DIR=$(dirname "$0")
cd /tmp/ppbhx-build

echo "== backing up pristine production source =="
cp "$SRC" "$SRC.hxorig"
sha256 "$SRC.hxorig"

echo "== PHASE A: DF-5418 fix only (!spin -> spin < 0) =="
cp "$DIR/ppb_1284.fixA.c" "$SRC"
grep -n 'spin < 0' "$SRC"
rm -f *.o ppbharness.ko
make SYSDIR=/usr/src/sys 2>&1 | tail -2
[ -f ppbharness.ko ] || { echo "FIX-A BUILD FAILED"; exit 1; }
kldload ./ppbharness.ko
dmesg | grep 'PPBHX: DF-5418'
kldunload ppbharness

echo "== PHASE B: DF-5418 + DF-5419 fixes =="
cp "$DIR/ppb_1284.fixB.c" "$SRC"
grep -n '\*read = 0;' "$SRC"
rm -f *.o ppbharness.ko
make SYSDIR=/usr/src/sys 2>&1 | tail -2
[ -f ppbharness.ko ] || { echo "FIX-B BUILD FAILED"; exit 1; }
kldload ./ppbharness.ko
dmesg | grep -E 'PPBHX: DF-5418|PPBHX: DF-5419'
kldunload ppbharness

echo "== restoring pristine production source =="
cp "$SRC.hxorig" "$SRC"
cmp "$SRC" "$SRC.hxorig" && echo "restore verified"
echo "PPBHX: fix validation complete"