DragonFlyBSD Kernel Audit
DF-2905 / run.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-2905 run script — run INSIDE the guest as root (sh run.sh).
# Protocol: measure live mbufs (mbread) around each kldload; the module
# performs its test at MOD_LOAD time.
#   baseline tail  : expect delta +8  (2 leaked records x 4 mbufs)
#   baseline walk  : expect delta  0  (walking frees each record)
#   fixed    tail  : expect delta  0
#   fixed    walk  : expect delta  0
set -e
cd /root/df2905

run_one() {
  tag=$1; dir=$2
  before=$(./mbread)
  kldload ${dir}/mchainleak.ko
  sleep 1
  after=$(./mbread)
  kldunload mchainleak 2>/dev/null || true
  echo "RESULT ${tag}: before=${before} after=${after} delta=$((after - before))"
}

echo "guest: $(uname -a)"
run_one baseline-tail build_base_tail
run_one baseline-walk build_base_walk
run_one fixed-tail    build_fix_tail
run_one fixed-walk    build_fix_walk
echo "DONE"